[Java] Update auto-generated Java bindings with new upstream getters
[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 LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
1753         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
1754         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
1755         return ret;
1756 }
1757 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1758 CHECK(owner->result_ok);
1759         return PaymentParameters_clone(&*owner->contents.result);
1760 }
1761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1762         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1763         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1764         int64_t ret_ref = 0;
1765         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1766         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1768         ret_ref = (uintptr_t)ret_var.inner;
1769         if (ret_var.is_owned) {
1770                 ret_ref |= 1;
1771         }
1772         return ret_ref;
1773 }
1774
1775 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1776 CHECK(!owner->result_ok);
1777         return DecodeError_clone(&*owner->contents.err);
1778 }
1779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1780         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1781         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1782         int64_t ret_ref = 0;
1783         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1784         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1786         ret_ref = (uintptr_t)ret_var.inner;
1787         if (ret_var.is_owned) {
1788                 ret_ref |= 1;
1789         }
1790         return ret_ref;
1791 }
1792
1793 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1794         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1795         for (size_t i = 0; i < ret.datalen; i++) {
1796                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1797         }
1798         return ret;
1799 }
1800 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1801 CHECK(owner->result_ok);
1802         return RouteHint_clone(&*owner->contents.result);
1803 }
1804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1805         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1806         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1807         int64_t ret_ref = 0;
1808         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1809         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1811         ret_ref = (uintptr_t)ret_var.inner;
1812         if (ret_var.is_owned) {
1813                 ret_ref |= 1;
1814         }
1815         return ret_ref;
1816 }
1817
1818 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1819 CHECK(!owner->result_ok);
1820         return DecodeError_clone(&*owner->contents.err);
1821 }
1822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1823         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1824         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1825         int64_t ret_ref = 0;
1826         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1827         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1829         ret_ref = (uintptr_t)ret_var.inner;
1830         if (ret_var.is_owned) {
1831                 ret_ref |= 1;
1832         }
1833         return ret_ref;
1834 }
1835
1836 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1837 CHECK(owner->result_ok);
1838         return RouteHintHop_clone(&*owner->contents.result);
1839 }
1840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1841         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1842         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1843         int64_t ret_ref = 0;
1844         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1845         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1847         ret_ref = (uintptr_t)ret_var.inner;
1848         if (ret_var.is_owned) {
1849                 ret_ref |= 1;
1850         }
1851         return ret_ref;
1852 }
1853
1854 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1855 CHECK(!owner->result_ok);
1856         return DecodeError_clone(&*owner->contents.err);
1857 }
1858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1859         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1860         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1861         int64_t ret_ref = 0;
1862         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1863         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1865         ret_ref = (uintptr_t)ret_var.inner;
1866         if (ret_var.is_owned) {
1867                 ret_ref |= 1;
1868         }
1869         return ret_ref;
1870 }
1871
1872 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1873         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1874         for (size_t i = 0; i < ret.datalen; i++) {
1875                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1876         }
1877         return ret;
1878 }
1879 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1880 CHECK(owner->result_ok);
1881         return Route_clone(&*owner->contents.result);
1882 }
1883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1884         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1885         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1886         int64_t ret_ref = 0;
1887         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1888         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1890         ret_ref = (uintptr_t)ret_var.inner;
1891         if (ret_var.is_owned) {
1892                 ret_ref |= 1;
1893         }
1894         return ret_ref;
1895 }
1896
1897 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1898 CHECK(!owner->result_ok);
1899         return LightningError_clone(&*owner->contents.err);
1900 }
1901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1902         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1903         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1904         int64_t ret_ref = 0;
1905         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1906         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1908         ret_ref = (uintptr_t)ret_var.inner;
1909         if (ret_var.is_owned) {
1910                 ret_ref |= 1;
1911         }
1912         return ret_ref;
1913 }
1914
1915 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
1916 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
1917 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
1918 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
1919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
1920         LDKPaymentPurpose_InvoicePayment_class =
1921                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
1922         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
1923         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
1924         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
1925         LDKPaymentPurpose_SpontaneousPayment_class =
1926                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
1927         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
1928         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
1929         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
1930 }
1931 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1932         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1933         switch(obj->tag) {
1934                 case LDKPaymentPurpose_InvoicePayment: {
1935                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
1936                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
1937                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
1938                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
1939                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
1940                 }
1941                 case LDKPaymentPurpose_SpontaneousPayment: {
1942                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
1943                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
1944                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
1945                 }
1946                 default: abort();
1947         }
1948 }
1949 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1950 CHECK(owner->result_ok);
1951         return PaymentPurpose_clone(&*owner->contents.result);
1952 }
1953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1954         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1955         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
1956         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
1957         int64_t ret_ref = (uintptr_t)ret_copy;
1958         return ret_ref;
1959 }
1960
1961 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1962 CHECK(!owner->result_ok);
1963         return DecodeError_clone(&*owner->contents.err);
1964 }
1965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1966         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1967         LDKDecodeError ret_var = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
1968         int64_t ret_ref = 0;
1969         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1970         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1972         ret_ref = (uintptr_t)ret_var.inner;
1973         if (ret_var.is_owned) {
1974                 ret_ref |= 1;
1975         }
1976         return ret_ref;
1977 }
1978
1979 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
1980 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
1981 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
1982 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
1983 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
1984 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
1985 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
1986 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
1987 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
1988 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
1989 static jclass LDKClosureReason_ProcessingError_class = NULL;
1990 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
1991 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
1992 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
1993 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
1994 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
1995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
1996         LDKClosureReason_CounterpartyForceClosed_class =
1997                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
1998         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
1999         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
2000         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
2001         LDKClosureReason_HolderForceClosed_class =
2002                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
2003         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
2004         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
2005         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
2006         LDKClosureReason_CooperativeClosure_class =
2007                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
2008         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
2009         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
2010         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
2011         LDKClosureReason_CommitmentTxConfirmed_class =
2012                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
2013         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
2014         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
2015         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
2016         LDKClosureReason_FundingTimedOut_class =
2017                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
2018         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
2019         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
2020         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
2021         LDKClosureReason_ProcessingError_class =
2022                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
2023         CHECK(LDKClosureReason_ProcessingError_class != NULL);
2024         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
2025         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
2026         LDKClosureReason_DisconnectedPeer_class =
2027                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
2028         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
2029         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
2030         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
2031         LDKClosureReason_OutdatedChannelManager_class =
2032                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
2033         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
2034         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
2035         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
2036 }
2037 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2038         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
2039         switch(obj->tag) {
2040                 case LDKClosureReason_CounterpartyForceClosed: {
2041                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
2042                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
2043                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
2044                 }
2045                 case LDKClosureReason_HolderForceClosed: {
2046                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
2047                 }
2048                 case LDKClosureReason_CooperativeClosure: {
2049                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
2050                 }
2051                 case LDKClosureReason_CommitmentTxConfirmed: {
2052                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
2053                 }
2054                 case LDKClosureReason_FundingTimedOut: {
2055                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
2056                 }
2057                 case LDKClosureReason_ProcessingError: {
2058                         LDKStr err_str = obj->processing_error.err;
2059                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2060                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
2061                 }
2062                 case LDKClosureReason_DisconnectedPeer: {
2063                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
2064                 }
2065                 case LDKClosureReason_OutdatedChannelManager: {
2066                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
2067                 }
2068                 default: abort();
2069         }
2070 }
2071 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
2072 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
2073 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
2074 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
2075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
2076         LDKCOption_ClosureReasonZ_Some_class =
2077                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
2078         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
2079         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
2080         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
2081         LDKCOption_ClosureReasonZ_None_class =
2082                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
2083         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
2084         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
2085         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
2086 }
2087 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2088         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
2089         switch(obj->tag) {
2090                 case LDKCOption_ClosureReasonZ_Some: {
2091                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2092                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
2093                 }
2094                 case LDKCOption_ClosureReasonZ_None: {
2095                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
2096                 }
2097                 default: abort();
2098         }
2099 }
2100 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2101 CHECK(owner->result_ok);
2102         return COption_ClosureReasonZ_clone(&*owner->contents.result);
2103 }
2104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2105         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2106         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
2107         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
2108         int64_t ret_ref = (uintptr_t)ret_copy;
2109         return ret_ref;
2110 }
2111
2112 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2113 CHECK(!owner->result_ok);
2114         return DecodeError_clone(&*owner->contents.err);
2115 }
2116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2117         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2118         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
2119         int64_t ret_ref = 0;
2120         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2121         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2123         ret_ref = (uintptr_t)ret_var.inner;
2124         if (ret_var.is_owned) {
2125                 ret_ref |= 1;
2126         }
2127         return ret_ref;
2128 }
2129
2130 static jclass LDKHTLCDestination_NextHopChannel_class = NULL;
2131 static jmethodID LDKHTLCDestination_NextHopChannel_meth = NULL;
2132 static jclass LDKHTLCDestination_UnknownNextHop_class = NULL;
2133 static jmethodID LDKHTLCDestination_UnknownNextHop_meth = NULL;
2134 static jclass LDKHTLCDestination_FailedPayment_class = NULL;
2135 static jmethodID LDKHTLCDestination_FailedPayment_meth = NULL;
2136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCDestination_init (JNIEnv *env, jclass clz) {
2137         LDKHTLCDestination_NextHopChannel_class =
2138                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$NextHopChannel"));
2139         CHECK(LDKHTLCDestination_NextHopChannel_class != NULL);
2140         LDKHTLCDestination_NextHopChannel_meth = (*env)->GetMethodID(env, LDKHTLCDestination_NextHopChannel_class, "<init>", "([B[B)V");
2141         CHECK(LDKHTLCDestination_NextHopChannel_meth != NULL);
2142         LDKHTLCDestination_UnknownNextHop_class =
2143                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$UnknownNextHop"));
2144         CHECK(LDKHTLCDestination_UnknownNextHop_class != NULL);
2145         LDKHTLCDestination_UnknownNextHop_meth = (*env)->GetMethodID(env, LDKHTLCDestination_UnknownNextHop_class, "<init>", "(J)V");
2146         CHECK(LDKHTLCDestination_UnknownNextHop_meth != NULL);
2147         LDKHTLCDestination_FailedPayment_class =
2148                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$FailedPayment"));
2149         CHECK(LDKHTLCDestination_FailedPayment_class != NULL);
2150         LDKHTLCDestination_FailedPayment_meth = (*env)->GetMethodID(env, LDKHTLCDestination_FailedPayment_class, "<init>", "([B)V");
2151         CHECK(LDKHTLCDestination_FailedPayment_meth != NULL);
2152 }
2153 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2154         LDKHTLCDestination *obj = (LDKHTLCDestination*)(ptr & ~1);
2155         switch(obj->tag) {
2156                 case LDKHTLCDestination_NextHopChannel: {
2157                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2158                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->next_hop_channel.node_id.compressed_form);
2159                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2160                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->next_hop_channel.channel_id.data);
2161                         return (*env)->NewObject(env, LDKHTLCDestination_NextHopChannel_class, LDKHTLCDestination_NextHopChannel_meth, node_id_arr, channel_id_arr);
2162                 }
2163                 case LDKHTLCDestination_UnknownNextHop: {
2164                         int64_t requested_forward_scid_conv = obj->unknown_next_hop.requested_forward_scid;
2165                         return (*env)->NewObject(env, LDKHTLCDestination_UnknownNextHop_class, LDKHTLCDestination_UnknownNextHop_meth, requested_forward_scid_conv);
2166                 }
2167                 case LDKHTLCDestination_FailedPayment: {
2168                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2169                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->failed_payment.payment_hash.data);
2170                         return (*env)->NewObject(env, LDKHTLCDestination_FailedPayment_class, LDKHTLCDestination_FailedPayment_meth, payment_hash_arr);
2171                 }
2172                 default: abort();
2173         }
2174 }
2175 static jclass LDKCOption_HTLCDestinationZ_Some_class = NULL;
2176 static jmethodID LDKCOption_HTLCDestinationZ_Some_meth = NULL;
2177 static jclass LDKCOption_HTLCDestinationZ_None_class = NULL;
2178 static jmethodID LDKCOption_HTLCDestinationZ_None_meth = NULL;
2179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1HTLCDestinationZ_init (JNIEnv *env, jclass clz) {
2180         LDKCOption_HTLCDestinationZ_Some_class =
2181                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$Some"));
2182         CHECK(LDKCOption_HTLCDestinationZ_Some_class != NULL);
2183         LDKCOption_HTLCDestinationZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_Some_class, "<init>", "(J)V");
2184         CHECK(LDKCOption_HTLCDestinationZ_Some_meth != NULL);
2185         LDKCOption_HTLCDestinationZ_None_class =
2186                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$None"));
2187         CHECK(LDKCOption_HTLCDestinationZ_None_class != NULL);
2188         LDKCOption_HTLCDestinationZ_None_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_None_class, "<init>", "()V");
2189         CHECK(LDKCOption_HTLCDestinationZ_None_meth != NULL);
2190 }
2191 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1HTLCDestinationZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2192         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)(ptr & ~1);
2193         switch(obj->tag) {
2194                 case LDKCOption_HTLCDestinationZ_Some: {
2195                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2196                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_Some_class, LDKCOption_HTLCDestinationZ_Some_meth, some_ref);
2197                 }
2198                 case LDKCOption_HTLCDestinationZ_None: {
2199                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_None_class, LDKCOption_HTLCDestinationZ_None_meth);
2200                 }
2201                 default: abort();
2202         }
2203 }
2204 static inline struct LDKCOption_HTLCDestinationZ CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
2205 CHECK(owner->result_ok);
2206         return COption_HTLCDestinationZ_clone(&*owner->contents.result);
2207 }
2208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2209         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(owner & ~1);
2210         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
2211         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(owner_conv);
2212         int64_t ret_ref = (uintptr_t)ret_copy;
2213         return ret_ref;
2214 }
2215
2216 static inline struct LDKDecodeError CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
2217 CHECK(!owner->result_ok);
2218         return DecodeError_clone(&*owner->contents.err);
2219 }
2220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2221         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(owner & ~1);
2222         LDKDecodeError ret_var = CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(owner_conv);
2223         int64_t ret_ref = 0;
2224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2227         ret_ref = (uintptr_t)ret_var.inner;
2228         if (ret_var.is_owned) {
2229                 ret_ref |= 1;
2230         }
2231         return ret_ref;
2232 }
2233
2234 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2235 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2236 static jclass LDKNetworkUpdate_ChannelFailure_class = NULL;
2237 static jmethodID LDKNetworkUpdate_ChannelFailure_meth = NULL;
2238 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2239 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2241         LDKNetworkUpdate_ChannelUpdateMessage_class =
2242                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2243         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2244         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2245         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2246         LDKNetworkUpdate_ChannelFailure_class =
2247                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelFailure"));
2248         CHECK(LDKNetworkUpdate_ChannelFailure_class != NULL);
2249         LDKNetworkUpdate_ChannelFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelFailure_class, "<init>", "(JZ)V");
2250         CHECK(LDKNetworkUpdate_ChannelFailure_meth != NULL);
2251         LDKNetworkUpdate_NodeFailure_class =
2252                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2253         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2254         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2255         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2256 }
2257 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2258         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
2259         switch(obj->tag) {
2260                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2261                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2262                         int64_t msg_ref = 0;
2263                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2264                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2265                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2266                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2267                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2268                 }
2269                 case LDKNetworkUpdate_ChannelFailure: {
2270                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
2271                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
2272                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelFailure_class, LDKNetworkUpdate_ChannelFailure_meth, short_channel_id_conv, is_permanent_conv);
2273                 }
2274                 case LDKNetworkUpdate_NodeFailure: {
2275                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2276                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2277                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
2278                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, is_permanent_conv);
2279                 }
2280                 default: abort();
2281         }
2282 }
2283 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2284 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2285 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2286 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2288         LDKCOption_NetworkUpdateZ_Some_class =
2289                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2290         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2291         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2292         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2293         LDKCOption_NetworkUpdateZ_None_class =
2294                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2295         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2296         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2297         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2298 }
2299 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2300         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
2301         switch(obj->tag) {
2302                 case LDKCOption_NetworkUpdateZ_Some: {
2303                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2304                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2305                 }
2306                 case LDKCOption_NetworkUpdateZ_None: {
2307                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2308                 }
2309                 default: abort();
2310         }
2311 }
2312 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
2313 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
2314 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
2315 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
2316 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
2317 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
2318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
2319         LDKSpendableOutputDescriptor_StaticOutput_class =
2320                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
2321         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
2322         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
2323         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
2324         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
2325                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
2326         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
2327         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
2328         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
2329         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
2330                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
2331         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
2332         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
2333         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
2334 }
2335 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2336         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
2337         switch(obj->tag) {
2338                 case LDKSpendableOutputDescriptor_StaticOutput: {
2339                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
2340                         int64_t outpoint_ref = 0;
2341                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2342                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2343                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
2344                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
2345                         int64_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
2346                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (int64_t)output_ref);
2347                 }
2348                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
2349                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
2350                         int64_t delayed_payment_output_ref = 0;
2351                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2352                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2353                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
2354                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
2355                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
2356                 }
2357                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
2358                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
2359                         int64_t static_payment_output_ref = 0;
2360                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2361                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2362                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
2363                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
2364                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
2365                 }
2366                 default: abort();
2367         }
2368 }
2369 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
2370         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
2371         for (size_t i = 0; i < ret.datalen; i++) {
2372                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
2373         }
2374         return ret;
2375 }
2376 static jclass LDKEvent_FundingGenerationReady_class = NULL;
2377 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
2378 static jclass LDKEvent_PaymentReceived_class = NULL;
2379 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
2380 static jclass LDKEvent_PaymentClaimed_class = NULL;
2381 static jmethodID LDKEvent_PaymentClaimed_meth = NULL;
2382 static jclass LDKEvent_PaymentSent_class = NULL;
2383 static jmethodID LDKEvent_PaymentSent_meth = NULL;
2384 static jclass LDKEvent_PaymentFailed_class = NULL;
2385 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
2386 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
2387 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
2388 static jclass LDKEvent_PaymentPathFailed_class = NULL;
2389 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
2390 static jclass LDKEvent_ProbeSuccessful_class = NULL;
2391 static jmethodID LDKEvent_ProbeSuccessful_meth = NULL;
2392 static jclass LDKEvent_ProbeFailed_class = NULL;
2393 static jmethodID LDKEvent_ProbeFailed_meth = NULL;
2394 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
2395 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
2396 static jclass LDKEvent_SpendableOutputs_class = NULL;
2397 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
2398 static jclass LDKEvent_PaymentForwarded_class = NULL;
2399 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
2400 static jclass LDKEvent_ChannelClosed_class = NULL;
2401 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
2402 static jclass LDKEvent_DiscardFunding_class = NULL;
2403 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
2404 static jclass LDKEvent_OpenChannelRequest_class = NULL;
2405 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
2406 static jclass LDKEvent_HTLCHandlingFailed_class = NULL;
2407 static jmethodID LDKEvent_HTLCHandlingFailed_meth = NULL;
2408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
2409         LDKEvent_FundingGenerationReady_class =
2410                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
2411         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
2412         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([B[BJ[BJ)V");
2413         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
2414         LDKEvent_PaymentReceived_class =
2415                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentReceived"));
2416         CHECK(LDKEvent_PaymentReceived_class != NULL);
2417         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
2418         CHECK(LDKEvent_PaymentReceived_meth != NULL);
2419         LDKEvent_PaymentClaimed_class =
2420                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimed"));
2421         CHECK(LDKEvent_PaymentClaimed_class != NULL);
2422         LDKEvent_PaymentClaimed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimed_class, "<init>", "([BJJ)V");
2423         CHECK(LDKEvent_PaymentClaimed_meth != NULL);
2424         LDKEvent_PaymentSent_class =
2425                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
2426         CHECK(LDKEvent_PaymentSent_class != NULL);
2427         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
2428         CHECK(LDKEvent_PaymentSent_meth != NULL);
2429         LDKEvent_PaymentFailed_class =
2430                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
2431         CHECK(LDKEvent_PaymentFailed_class != NULL);
2432         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
2433         CHECK(LDKEvent_PaymentFailed_meth != NULL);
2434         LDKEvent_PaymentPathSuccessful_class =
2435                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
2436         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
2437         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
2438         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
2439         LDKEvent_PaymentPathFailed_class =
2440                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
2441         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
2442         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
2443         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
2444         LDKEvent_ProbeSuccessful_class =
2445                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeSuccessful"));
2446         CHECK(LDKEvent_ProbeSuccessful_class != NULL);
2447         LDKEvent_ProbeSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_ProbeSuccessful_class, "<init>", "([B[B[J)V");
2448         CHECK(LDKEvent_ProbeSuccessful_meth != NULL);
2449         LDKEvent_ProbeFailed_class =
2450                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeFailed"));
2451         CHECK(LDKEvent_ProbeFailed_class != NULL);
2452         LDKEvent_ProbeFailed_meth = (*env)->GetMethodID(env, LDKEvent_ProbeFailed_class, "<init>", "([B[B[JJ)V");
2453         CHECK(LDKEvent_ProbeFailed_meth != NULL);
2454         LDKEvent_PendingHTLCsForwardable_class =
2455                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
2456         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
2457         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
2458         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
2459         LDKEvent_SpendableOutputs_class =
2460                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
2461         CHECK(LDKEvent_SpendableOutputs_class != NULL);
2462         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
2463         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
2464         LDKEvent_PaymentForwarded_class =
2465                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
2466         CHECK(LDKEvent_PaymentForwarded_class != NULL);
2467         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "([B[BJZ)V");
2468         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
2469         LDKEvent_ChannelClosed_class =
2470                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
2471         CHECK(LDKEvent_ChannelClosed_class != NULL);
2472         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
2473         CHECK(LDKEvent_ChannelClosed_meth != NULL);
2474         LDKEvent_DiscardFunding_class =
2475                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
2476         CHECK(LDKEvent_DiscardFunding_class != NULL);
2477         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
2478         CHECK(LDKEvent_DiscardFunding_meth != NULL);
2479         LDKEvent_OpenChannelRequest_class =
2480                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
2481         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
2482         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJJ)V");
2483         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
2484         LDKEvent_HTLCHandlingFailed_class =
2485                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$HTLCHandlingFailed"));
2486         CHECK(LDKEvent_HTLCHandlingFailed_class != NULL);
2487         LDKEvent_HTLCHandlingFailed_meth = (*env)->GetMethodID(env, LDKEvent_HTLCHandlingFailed_class, "<init>", "([BJ)V");
2488         CHECK(LDKEvent_HTLCHandlingFailed_meth != NULL);
2489 }
2490 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2491         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2492         switch(obj->tag) {
2493                 case LDKEvent_FundingGenerationReady: {
2494                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2495                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
2496                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2497                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->funding_generation_ready.counterparty_node_id.compressed_form);
2498                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
2499                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
2500                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
2501                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
2502                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
2503                         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);
2504                 }
2505                 case LDKEvent_PaymentReceived: {
2506                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2507                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
2508                         int64_t amount_msat_conv = obj->payment_received.amount_msat;
2509                         int64_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
2510                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
2511                 }
2512                 case LDKEvent_PaymentClaimed: {
2513                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2514                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimed.payment_hash.data);
2515                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
2516                         int64_t purpose_ref = ((uintptr_t)&obj->payment_claimed.purpose) | 1;
2517                         return (*env)->NewObject(env, LDKEvent_PaymentClaimed_class, LDKEvent_PaymentClaimed_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
2518                 }
2519                 case LDKEvent_PaymentSent: {
2520                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2521                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
2522                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2523                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
2524                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2525                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
2526                         int64_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
2527                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
2528                 }
2529                 case LDKEvent_PaymentFailed: {
2530                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2531                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
2532                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2533                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
2534                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
2535                 }
2536                 case LDKEvent_PaymentPathSuccessful: {
2537                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2538                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
2539                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2540                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
2541                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
2542                         int64_tArray path_arr = NULL;
2543                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2544                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2545                         for (size_t k = 0; k < path_var.datalen; k++) {
2546                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2547                                 int64_t path_conv_10_ref = 0;
2548                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2549                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2550                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2551                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2552                                 path_arr_ptr[k] = path_conv_10_ref;
2553                         }
2554                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2555                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
2556                 }
2557                 case LDKEvent_PaymentPathFailed: {
2558                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2559                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
2560                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2561                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
2562                         jboolean rejected_by_dest_conv = obj->payment_path_failed.rejected_by_dest;
2563                         int64_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
2564                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
2565                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
2566                         int64_tArray path_arr = NULL;
2567                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2568                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2569                         for (size_t k = 0; k < path_var.datalen; k++) {
2570                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2571                                 int64_t path_conv_10_ref = 0;
2572                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2573                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2574                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2575                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2576                                 path_arr_ptr[k] = path_conv_10_ref;
2577                         }
2578                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2579                         int64_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
2580                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
2581                         int64_t retry_ref = 0;
2582                         if ((uintptr_t)retry_var.inner > 4096) {
2583                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2584                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2585                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
2586                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
2587                         }
2588                         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);
2589                 }
2590                 case LDKEvent_ProbeSuccessful: {
2591                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2592                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_successful.payment_id.data);
2593                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2594                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_successful.payment_hash.data);
2595                         LDKCVec_RouteHopZ path_var = obj->probe_successful.path;
2596                         int64_tArray path_arr = NULL;
2597                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2598                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2599                         for (size_t k = 0; k < path_var.datalen; k++) {
2600                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2601                                 int64_t path_conv_10_ref = 0;
2602                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2603                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2604                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2605                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2606                                 path_arr_ptr[k] = path_conv_10_ref;
2607                         }
2608                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2609                         return (*env)->NewObject(env, LDKEvent_ProbeSuccessful_class, LDKEvent_ProbeSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
2610                 }
2611                 case LDKEvent_ProbeFailed: {
2612                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2613                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_failed.payment_id.data);
2614                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2615                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_failed.payment_hash.data);
2616                         LDKCVec_RouteHopZ path_var = obj->probe_failed.path;
2617                         int64_tArray path_arr = NULL;
2618                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2619                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2620                         for (size_t k = 0; k < path_var.datalen; k++) {
2621                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2622                                 int64_t path_conv_10_ref = 0;
2623                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2624                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2625                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2626                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2627                                 path_arr_ptr[k] = path_conv_10_ref;
2628                         }
2629                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2630                         int64_t short_channel_id_ref = ((uintptr_t)&obj->probe_failed.short_channel_id) | 1;
2631                         return (*env)->NewObject(env, LDKEvent_ProbeFailed_class, LDKEvent_ProbeFailed_meth, payment_id_arr, payment_hash_arr, path_arr, short_channel_id_ref);
2632                 }
2633                 case LDKEvent_PendingHTLCsForwardable: {
2634                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
2635                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, time_forwardable_conv);
2636                 }
2637                 case LDKEvent_SpendableOutputs: {
2638                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
2639                         int64_tArray outputs_arr = NULL;
2640                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
2641                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
2642                         for (size_t b = 0; b < outputs_var.datalen; b++) {
2643                                 int64_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
2644                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
2645                         }
2646                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
2647                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
2648                 }
2649                 case LDKEvent_PaymentForwarded: {
2650                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
2651                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->payment_forwarded.prev_channel_id.data);
2652                         int8_tArray next_channel_id_arr = (*env)->NewByteArray(env, 32);
2653                         (*env)->SetByteArrayRegion(env, next_channel_id_arr, 0, 32, obj->payment_forwarded.next_channel_id.data);
2654                         int64_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
2655                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
2656                         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);
2657                 }
2658                 case LDKEvent_ChannelClosed: {
2659                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2660                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
2661                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
2662                         int64_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
2663                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, user_channel_id_conv, reason_ref);
2664                 }
2665                 case LDKEvent_DiscardFunding: {
2666                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2667                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
2668                         LDKTransaction transaction_var = obj->discard_funding.transaction;
2669                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
2670                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
2671                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
2672                 }
2673                 case LDKEvent_OpenChannelRequest: {
2674                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2675                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
2676                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2677                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
2678                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
2679                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
2680                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
2681                         int64_t channel_type_ref = 0;
2682                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2683                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2684                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
2685                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
2686                         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);
2687                 }
2688                 case LDKEvent_HTLCHandlingFailed: {
2689                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
2690                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->htlc_handling_failed.prev_channel_id.data);
2691                         int64_t failed_next_destination_ref = ((uintptr_t)&obj->htlc_handling_failed.failed_next_destination) | 1;
2692                         return (*env)->NewObject(env, LDKEvent_HTLCHandlingFailed_class, LDKEvent_HTLCHandlingFailed_meth, prev_channel_id_arr, failed_next_destination_ref);
2693                 }
2694                 default: abort();
2695         }
2696 }
2697 static jclass LDKCOption_EventZ_Some_class = NULL;
2698 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
2699 static jclass LDKCOption_EventZ_None_class = NULL;
2700 static jmethodID LDKCOption_EventZ_None_meth = NULL;
2701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
2702         LDKCOption_EventZ_Some_class =
2703                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
2704         CHECK(LDKCOption_EventZ_Some_class != NULL);
2705         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
2706         CHECK(LDKCOption_EventZ_Some_meth != NULL);
2707         LDKCOption_EventZ_None_class =
2708                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
2709         CHECK(LDKCOption_EventZ_None_class != NULL);
2710         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
2711         CHECK(LDKCOption_EventZ_None_meth != NULL);
2712 }
2713 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2714         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2715         switch(obj->tag) {
2716                 case LDKCOption_EventZ_Some: {
2717                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2718                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
2719                 }
2720                 case LDKCOption_EventZ_None: {
2721                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
2722                 }
2723                 default: abort();
2724         }
2725 }
2726 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2727 CHECK(owner->result_ok);
2728         return COption_EventZ_clone(&*owner->contents.result);
2729 }
2730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2731         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2732         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
2733         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
2734         int64_t ret_ref = (uintptr_t)ret_copy;
2735         return ret_ref;
2736 }
2737
2738 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2739 CHECK(!owner->result_ok);
2740         return DecodeError_clone(&*owner->contents.err);
2741 }
2742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2743         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2744         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
2745         int64_t ret_ref = 0;
2746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2749         ret_ref = (uintptr_t)ret_var.inner;
2750         if (ret_var.is_owned) {
2751                 ret_ref |= 1;
2752         }
2753         return ret_ref;
2754 }
2755
2756 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
2757 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
2758 static jclass LDKErrorAction_IgnoreError_class = NULL;
2759 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
2760 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
2761 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
2762 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
2763 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
2764 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
2765 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
2766 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
2767 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
2768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
2769         LDKErrorAction_DisconnectPeer_class =
2770                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
2771         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
2772         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
2773         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
2774         LDKErrorAction_IgnoreError_class =
2775                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
2776         CHECK(LDKErrorAction_IgnoreError_class != NULL);
2777         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
2778         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
2779         LDKErrorAction_IgnoreAndLog_class =
2780                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
2781         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
2782         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
2783         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
2784         LDKErrorAction_IgnoreDuplicateGossip_class =
2785                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
2786         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
2787         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
2788         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
2789         LDKErrorAction_SendErrorMessage_class =
2790                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
2791         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
2792         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
2793         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
2794         LDKErrorAction_SendWarningMessage_class =
2795                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
2796         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
2797         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
2798         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
2799 }
2800 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2801         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2802         switch(obj->tag) {
2803                 case LDKErrorAction_DisconnectPeer: {
2804                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2805                         int64_t msg_ref = 0;
2806                         if ((uintptr_t)msg_var.inner > 4096) {
2807                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2808                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2809                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2810                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
2811                         }
2812                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
2813                 }
2814                 case LDKErrorAction_IgnoreError: {
2815                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
2816                 }
2817                 case LDKErrorAction_IgnoreAndLog: {
2818                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
2819                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
2820                 }
2821                 case LDKErrorAction_IgnoreDuplicateGossip: {
2822                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
2823                 }
2824                 case LDKErrorAction_SendErrorMessage: {
2825                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2826                         int64_t msg_ref = 0;
2827                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2828                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2829                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2830                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2831                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
2832                 }
2833                 case LDKErrorAction_SendWarningMessage: {
2834                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2835                         int64_t msg_ref = 0;
2836                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2837                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2838                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2839                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2840                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
2841                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
2842                 }
2843                 default: abort();
2844         }
2845 }
2846 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
2847 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
2848 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
2849 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
2850 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
2851 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
2852 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
2853 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
2854 static jclass LDKMessageSendEvent_SendChannelReady_class = NULL;
2855 static jmethodID LDKMessageSendEvent_SendChannelReady_meth = NULL;
2856 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
2857 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
2858 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
2859 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
2860 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
2861 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
2862 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
2863 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
2864 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
2865 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
2866 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
2867 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
2868 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
2869 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
2870 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
2871 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
2872 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
2873 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
2874 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
2875 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
2876 static jclass LDKMessageSendEvent_HandleError_class = NULL;
2877 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
2878 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
2879 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
2880 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
2881 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
2882 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
2883 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
2884 static jclass LDKMessageSendEvent_SendGossipTimestampFilter_class = NULL;
2885 static jmethodID LDKMessageSendEvent_SendGossipTimestampFilter_meth = NULL;
2886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
2887         LDKMessageSendEvent_SendAcceptChannel_class =
2888                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
2889         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
2890         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
2891         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
2892         LDKMessageSendEvent_SendOpenChannel_class =
2893                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
2894         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
2895         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
2896         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
2897         LDKMessageSendEvent_SendFundingCreated_class =
2898                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
2899         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
2900         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
2901         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
2902         LDKMessageSendEvent_SendFundingSigned_class =
2903                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
2904         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
2905         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
2906         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
2907         LDKMessageSendEvent_SendChannelReady_class =
2908                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReady"));
2909         CHECK(LDKMessageSendEvent_SendChannelReady_class != NULL);
2910         LDKMessageSendEvent_SendChannelReady_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReady_class, "<init>", "([BJ)V");
2911         CHECK(LDKMessageSendEvent_SendChannelReady_meth != NULL);
2912         LDKMessageSendEvent_SendAnnouncementSignatures_class =
2913                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
2914         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
2915         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
2916         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
2917         LDKMessageSendEvent_UpdateHTLCs_class =
2918                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
2919         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
2920         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
2921         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
2922         LDKMessageSendEvent_SendRevokeAndACK_class =
2923                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
2924         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
2925         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
2926         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
2927         LDKMessageSendEvent_SendClosingSigned_class =
2928                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
2929         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
2930         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
2931         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
2932         LDKMessageSendEvent_SendShutdown_class =
2933                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
2934         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
2935         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
2936         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
2937         LDKMessageSendEvent_SendChannelReestablish_class =
2938                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
2939         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
2940         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
2941         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
2942         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
2943                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
2944         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
2945         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
2946         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
2947         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
2948                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement"));
2949         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
2950         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
2951         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
2952         LDKMessageSendEvent_BroadcastChannelUpdate_class =
2953                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
2954         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
2955         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
2956         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
2957         LDKMessageSendEvent_SendChannelUpdate_class =
2958                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
2959         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
2960         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
2961         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
2962         LDKMessageSendEvent_HandleError_class =
2963                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
2964         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
2965         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
2966         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
2967         LDKMessageSendEvent_SendChannelRangeQuery_class =
2968                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
2969         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
2970         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
2971         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
2972         LDKMessageSendEvent_SendShortIdsQuery_class =
2973                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
2974         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
2975         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
2976         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2977         LDKMessageSendEvent_SendReplyChannelRange_class =
2978                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
2979         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2980         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2981         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2982         LDKMessageSendEvent_SendGossipTimestampFilter_class =
2983                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendGossipTimestampFilter"));
2984         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_class != NULL);
2985         LDKMessageSendEvent_SendGossipTimestampFilter_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, "<init>", "([BJ)V");
2986         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_meth != NULL);
2987 }
2988 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2989         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2990         switch(obj->tag) {
2991                 case LDKMessageSendEvent_SendAcceptChannel: {
2992                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2993                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2994                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2995                         int64_t msg_ref = 0;
2996                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2997                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2998                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2999                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3000                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
3001                 }
3002                 case LDKMessageSendEvent_SendOpenChannel: {
3003                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3004                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
3005                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
3006                         int64_t msg_ref = 0;
3007                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3008                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3009                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3010                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3011                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
3012                 }
3013                 case LDKMessageSendEvent_SendFundingCreated: {
3014                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3015                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
3016                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
3017                         int64_t msg_ref = 0;
3018                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3019                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3020                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3021                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3022                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
3023                 }
3024                 case LDKMessageSendEvent_SendFundingSigned: {
3025                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3026                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
3027                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
3028                         int64_t msg_ref = 0;
3029                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3030                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3031                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3032                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3033                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
3034                 }
3035                 case LDKMessageSendEvent_SendChannelReady: {
3036                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3037                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_ready.node_id.compressed_form);
3038                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
3039                         int64_t msg_ref = 0;
3040                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3041                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3042                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3043                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3044                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReady_class, LDKMessageSendEvent_SendChannelReady_meth, node_id_arr, msg_ref);
3045                 }
3046                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
3047                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3048                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
3049                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
3050                         int64_t msg_ref = 0;
3051                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3052                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3053                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3054                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3055                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
3056                 }
3057                 case LDKMessageSendEvent_UpdateHTLCs: {
3058                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3059                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
3060                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
3061                         int64_t updates_ref = 0;
3062                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3063                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3064                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
3065                         updates_ref = (uintptr_t)updates_var.inner & ~1;
3066                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
3067                 }
3068                 case LDKMessageSendEvent_SendRevokeAndACK: {
3069                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3070                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
3071                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
3072                         int64_t msg_ref = 0;
3073                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3074                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3075                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3076                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3077                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
3078                 }
3079                 case LDKMessageSendEvent_SendClosingSigned: {
3080                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3081                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
3082                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
3083                         int64_t msg_ref = 0;
3084                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3085                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3086                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3087                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3088                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
3089                 }
3090                 case LDKMessageSendEvent_SendShutdown: {
3091                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3092                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
3093                         LDKShutdown msg_var = obj->send_shutdown.msg;
3094                         int64_t msg_ref = 0;
3095                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3096                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3097                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3098                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3099                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
3100                 }
3101                 case LDKMessageSendEvent_SendChannelReestablish: {
3102                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3103                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
3104                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
3105                         int64_t msg_ref = 0;
3106                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3107                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3108                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3109                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3110                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
3111                 }
3112                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
3113                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
3114                         int64_t msg_ref = 0;
3115                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3116                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3117                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3118                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3119                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
3120                         int64_t update_msg_ref = 0;
3121                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3122                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3123                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3124                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
3125                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
3126                 }
3127                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
3128                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
3129                         int64_t msg_ref = 0;
3130                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3131                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3132                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3133                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3134                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
3135                 }
3136                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
3137                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
3138                         int64_t msg_ref = 0;
3139                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3140                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3141                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3142                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3143                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
3144                 }
3145                 case LDKMessageSendEvent_SendChannelUpdate: {
3146                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3147                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
3148                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
3149                         int64_t msg_ref = 0;
3150                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3151                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3152                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3153                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3154                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
3155                 }
3156                 case LDKMessageSendEvent_HandleError: {
3157                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3158                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
3159                         int64_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
3160                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
3161                 }
3162                 case LDKMessageSendEvent_SendChannelRangeQuery: {
3163                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3164                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
3165                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
3166                         int64_t msg_ref = 0;
3167                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3168                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3169                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3170                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3171                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
3172                 }
3173                 case LDKMessageSendEvent_SendShortIdsQuery: {
3174                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3175                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
3176                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
3177                         int64_t msg_ref = 0;
3178                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3179                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3180                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3181                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3182                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
3183                 }
3184                 case LDKMessageSendEvent_SendReplyChannelRange: {
3185                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3186                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
3187                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3188                         int64_t msg_ref = 0;
3189                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3190                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3191                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3192                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3193                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
3194                 }
3195                 case LDKMessageSendEvent_SendGossipTimestampFilter: {
3196                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3197                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_gossip_timestamp_filter.node_id.compressed_form);
3198                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
3199                         int64_t msg_ref = 0;
3200                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3201                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3202                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3203                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3204                         return (*env)->NewObject(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, LDKMessageSendEvent_SendGossipTimestampFilter_meth, node_id_arr, msg_ref);
3205                 }
3206                 default: abort();
3207         }
3208 }
3209 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3210         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3211         for (size_t i = 0; i < ret.datalen; i++) {
3212                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3213         }
3214         return ret;
3215 }
3216 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3217 CHECK(owner->result_ok);
3218         return TxOut_clone(&*owner->contents.result);
3219 }
3220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3221         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
3222         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3223         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
3224         return (int64_t)ret_ref;
3225 }
3226
3227 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3228 CHECK(!owner->result_ok);
3229         return AccessError_clone(&*owner->contents.err);
3230 }
3231 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3232         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
3233         jclass ret_conv = LDKAccessError_to_java(env, CResult_TxOutAccessErrorZ_get_err(owner_conv));
3234         return ret_conv;
3235 }
3236
3237 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3238         return owner->a;
3239 }
3240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3241         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
3242         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
3243         return ret_conv;
3244 }
3245
3246 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3247         return owner->b;
3248 }
3249 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3250         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
3251         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
3252         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3253         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3254         return ret_arr;
3255 }
3256
3257 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
3258         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
3259         for (size_t i = 0; i < ret.datalen; i++) {
3260                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
3261         }
3262         return ret;
3263 }
3264 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
3265         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
3266         for (size_t i = 0; i < ret.datalen; i++) {
3267                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3268         }
3269         return ret;
3270 }
3271 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3272 CHECK(owner->result_ok);
3273         return *owner->contents.result;
3274 }
3275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3276         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
3277         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
3278 }
3279
3280 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3281 CHECK(!owner->result_ok);
3282         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
3283 }
3284 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3285         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
3286         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
3287         return ret_conv;
3288 }
3289
3290 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
3291 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
3292 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
3293 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
3294 static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
3295 static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
3296 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
3297 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
3298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
3299         LDKMonitorEvent_HTLCEvent_class =
3300                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
3301         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
3302         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
3303         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
3304         LDKMonitorEvent_CommitmentTxConfirmed_class =
3305                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
3306         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
3307         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
3308         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
3309         LDKMonitorEvent_UpdateCompleted_class =
3310                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted"));
3311         CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
3312         LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
3313         CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
3314         LDKMonitorEvent_UpdateFailed_class =
3315                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
3316         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
3317         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
3318         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
3319 }
3320 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3321         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
3322         switch(obj->tag) {
3323                 case LDKMonitorEvent_HTLCEvent: {
3324                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
3325                         int64_t htlc_event_ref = 0;
3326                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3327                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3328                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
3329                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
3330                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
3331                 }
3332                 case LDKMonitorEvent_CommitmentTxConfirmed: {
3333                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
3334                         int64_t commitment_tx_confirmed_ref = 0;
3335                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3336                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3337                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
3338                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
3339                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
3340                 }
3341                 case LDKMonitorEvent_UpdateCompleted: {
3342                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
3343                         int64_t funding_txo_ref = 0;
3344                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3345                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3346                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
3347                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
3348                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
3349                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, monitor_update_id_conv);
3350                 }
3351                 case LDKMonitorEvent_UpdateFailed: {
3352                         LDKOutPoint update_failed_var = obj->update_failed;
3353                         int64_t update_failed_ref = 0;
3354                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3355                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3356                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
3357                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
3358                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
3359                 }
3360                 default: abort();
3361         }
3362 }
3363 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
3364         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
3365         for (size_t i = 0; i < ret.datalen; i++) {
3366                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
3367         }
3368         return ret;
3369 }
3370 static inline struct LDKOutPoint C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3371         return OutPoint_clone(&owner->a);
3372 }
3373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3374         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(owner & ~1);
3375         LDKOutPoint ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(owner_conv);
3376         int64_t ret_ref = 0;
3377         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3378         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3379         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3380         ret_ref = (uintptr_t)ret_var.inner;
3381         if (ret_var.is_owned) {
3382                 ret_ref |= 1;
3383         }
3384         return ret_ref;
3385 }
3386
3387 static inline struct LDKCVec_MonitorEventZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3388         return CVec_MonitorEventZ_clone(&owner->b);
3389 }
3390 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3391         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(owner & ~1);
3392         LDKCVec_MonitorEventZ ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(owner_conv);
3393         int64_tArray ret_arr = NULL;
3394         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3395         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3396         for (size_t o = 0; o < ret_var.datalen; o++) {
3397                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3398                 *ret_conv_14_copy = ret_var.data[o];
3399                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
3400                 ret_arr_ptr[o] = ret_conv_14_ref;
3401         }
3402         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3403         FREE(ret_var.data);
3404         return ret_arr;
3405 }
3406
3407 static inline struct LDKPublicKey C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3408         return owner->c;
3409 }
3410 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
3411         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(owner & ~1);
3412         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3413         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(owner_conv).compressed_form);
3414         return ret_arr;
3415 }
3416
3417 static inline LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_clone(const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ *orig) {
3418         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) * orig->datalen, "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ clone bytes"), .datalen = orig->datalen };
3419         for (size_t i = 0; i < ret.datalen; i++) {
3420                 ret.data[i] = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(&orig->data[i]);
3421         }
3422         return ret;
3423 }
3424 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
3425 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
3426 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
3427 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
3428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
3429         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
3430                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some"));
3431         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
3432         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
3433         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
3434         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
3435                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None"));
3436         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
3437         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
3438         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
3439 }
3440 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3441         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
3442         switch(obj->tag) {
3443                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
3444                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
3445                         *some_conv = obj->some;
3446                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
3447                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, ((int64_t)some_conv));
3448                 }
3449                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
3450                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
3451                 }
3452                 default: abort();
3453         }
3454 }
3455 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3456 CHECK(owner->result_ok);
3457         return FixedPenaltyScorer_clone(&*owner->contents.result);
3458 }
3459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3460         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3461         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3462         int64_t ret_ref = 0;
3463         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3464         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3466         ret_ref = (uintptr_t)ret_var.inner;
3467         if (ret_var.is_owned) {
3468                 ret_ref |= 1;
3469         }
3470         return ret_ref;
3471 }
3472
3473 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3474 CHECK(!owner->result_ok);
3475         return DecodeError_clone(&*owner->contents.err);
3476 }
3477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3478         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3479         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3480         int64_t ret_ref = 0;
3481         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3482         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3484         ret_ref = (uintptr_t)ret_var.inner;
3485         if (ret_var.is_owned) {
3486                 ret_ref |= 1;
3487         }
3488         return ret_ref;
3489 }
3490
3491 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3492         return owner->a;
3493 }
3494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3495         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
3496         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
3497         return ret_conv;
3498 }
3499
3500 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3501         return owner->b;
3502 }
3503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3504         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
3505         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
3506         return ret_conv;
3507 }
3508
3509 static jclass LDKCOption_C2Tuple_u64u64ZZ_Some_class = NULL;
3510 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_Some_meth = NULL;
3511 static jclass LDKCOption_C2Tuple_u64u64ZZ_None_class = NULL;
3512 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_None_meth = NULL;
3513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1u64u64ZZ_init (JNIEnv *env, jclass clz) {
3514         LDKCOption_C2Tuple_u64u64ZZ_Some_class =
3515                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$Some"));
3516         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_class != NULL);
3517         LDKCOption_C2Tuple_u64u64ZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, "<init>", "(J)V");
3518         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_meth != NULL);
3519         LDKCOption_C2Tuple_u64u64ZZ_None_class =
3520                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$None"));
3521         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_class != NULL);
3522         LDKCOption_C2Tuple_u64u64ZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, "<init>", "()V");
3523         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_meth != NULL);
3524 }
3525 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1u64u64ZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3526         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)(ptr & ~1);
3527         switch(obj->tag) {
3528                 case LDKCOption_C2Tuple_u64u64ZZ_Some: {
3529                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
3530                         *some_conv = obj->some;
3531                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
3532                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, LDKCOption_C2Tuple_u64u64ZZ_Some_meth, ((int64_t)some_conv));
3533                 }
3534                 case LDKCOption_C2Tuple_u64u64ZZ_None: {
3535                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, LDKCOption_C2Tuple_u64u64ZZ_None_meth);
3536                 }
3537                 default: abort();
3538         }
3539 }
3540 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
3541         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
3542         for (size_t i = 0; i < ret.datalen; i++) {
3543                 ret.data[i] = NodeId_clone(&orig->data[i]);
3544         }
3545         return ret;
3546 }
3547 typedef struct LDKLogger_JCalls {
3548         atomic_size_t refcnt;
3549         JavaVM *vm;
3550         jweak o;
3551         jmethodID log_meth;
3552 } LDKLogger_JCalls;
3553 static void LDKLogger_JCalls_free(void* this_arg) {
3554         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3555         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3556                 JNIEnv *env;
3557                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3558                 if (get_jenv_res == JNI_EDETACHED) {
3559                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3560                 } else {
3561                         DO_ASSERT(get_jenv_res == JNI_OK);
3562                 }
3563                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3564                 if (get_jenv_res == JNI_EDETACHED) {
3565                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3566                 }
3567                 FREE(j_calls);
3568         }
3569 }
3570 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
3571         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3572         JNIEnv *env;
3573         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3574         if (get_jenv_res == JNI_EDETACHED) {
3575                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3576         } else {
3577                 DO_ASSERT(get_jenv_res == JNI_OK);
3578         }
3579         LDKRecord record_var = *record;
3580         int64_t record_ref = 0;
3581         record_var = Record_clone(&record_var);
3582         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3583         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3584         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
3585         record_ref = (uintptr_t)record_var.inner;
3586         if (record_var.is_owned) {
3587                 record_ref |= 1;
3588         }
3589         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3590         CHECK(obj != NULL);
3591         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
3592         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3593                 (*env)->ExceptionDescribe(env);
3594                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
3595         }
3596         if (get_jenv_res == JNI_EDETACHED) {
3597                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3598         }
3599 }
3600 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
3601         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
3602         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3603 }
3604 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
3605         jclass c = (*env)->GetObjectClass(env, o);
3606         CHECK(c != NULL);
3607         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3608         atomic_init(&calls->refcnt, 1);
3609         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3610         calls->o = (*env)->NewWeakGlobalRef(env, o);
3611         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
3612         CHECK(calls->log_meth != NULL);
3613
3614         LDKLogger ret = {
3615                 .this_arg = (void*) calls,
3616                 .log = log_LDKLogger_jcall,
3617                 .free = LDKLogger_JCalls_free,
3618         };
3619         return ret;
3620 }
3621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
3622         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3623         *res_ptr = LDKLogger_init(env, clz, o);
3624         return (uint64_t)res_ptr;
3625 }
3626 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3627 CHECK(owner->result_ok);
3628         return &*owner->contents.result;
3629 }
3630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3631         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3632         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
3633         int64_t ret_ref = 0;
3634         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3635         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3637         ret_ref = (uintptr_t)ret_var.inner & ~1;
3638         return ret_ref;
3639 }
3640
3641 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3642 CHECK(!owner->result_ok);
3643         return DecodeError_clone(&*owner->contents.err);
3644 }
3645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3646         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3647         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
3648         int64_t ret_ref = 0;
3649         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3650         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3651         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3652         ret_ref = (uintptr_t)ret_var.inner;
3653         if (ret_var.is_owned) {
3654                 ret_ref |= 1;
3655         }
3656         return ret_ref;
3657 }
3658
3659 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3660 CHECK(owner->result_ok);
3661         return InitFeatures_clone(&*owner->contents.result);
3662 }
3663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3664         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3665         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
3666         int64_t ret_ref = 0;
3667         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3668         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3670         ret_ref = (uintptr_t)ret_var.inner;
3671         if (ret_var.is_owned) {
3672                 ret_ref |= 1;
3673         }
3674         return ret_ref;
3675 }
3676
3677 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3678 CHECK(!owner->result_ok);
3679         return DecodeError_clone(&*owner->contents.err);
3680 }
3681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3682         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3683         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
3684         int64_t ret_ref = 0;
3685         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3686         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3687         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3688         ret_ref = (uintptr_t)ret_var.inner;
3689         if (ret_var.is_owned) {
3690                 ret_ref |= 1;
3691         }
3692         return ret_ref;
3693 }
3694
3695 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3696 CHECK(owner->result_ok);
3697         return ChannelFeatures_clone(&*owner->contents.result);
3698 }
3699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3700         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3701         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
3702         int64_t ret_ref = 0;
3703         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3704         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3706         ret_ref = (uintptr_t)ret_var.inner;
3707         if (ret_var.is_owned) {
3708                 ret_ref |= 1;
3709         }
3710         return ret_ref;
3711 }
3712
3713 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3714 CHECK(!owner->result_ok);
3715         return DecodeError_clone(&*owner->contents.err);
3716 }
3717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3718         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3719         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
3720         int64_t ret_ref = 0;
3721         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3722         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3724         ret_ref = (uintptr_t)ret_var.inner;
3725         if (ret_var.is_owned) {
3726                 ret_ref |= 1;
3727         }
3728         return ret_ref;
3729 }
3730
3731 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3732 CHECK(owner->result_ok);
3733         return NodeFeatures_clone(&*owner->contents.result);
3734 }
3735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3736         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3737         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
3738         int64_t ret_ref = 0;
3739         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3740         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3742         ret_ref = (uintptr_t)ret_var.inner;
3743         if (ret_var.is_owned) {
3744                 ret_ref |= 1;
3745         }
3746         return ret_ref;
3747 }
3748
3749 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3750 CHECK(!owner->result_ok);
3751         return DecodeError_clone(&*owner->contents.err);
3752 }
3753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3754         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3755         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3756         int64_t ret_ref = 0;
3757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3760         ret_ref = (uintptr_t)ret_var.inner;
3761         if (ret_var.is_owned) {
3762                 ret_ref |= 1;
3763         }
3764         return ret_ref;
3765 }
3766
3767 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3768 CHECK(owner->result_ok);
3769         return InvoiceFeatures_clone(&*owner->contents.result);
3770 }
3771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3772         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3773         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3774         int64_t ret_ref = 0;
3775         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3776         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3778         ret_ref = (uintptr_t)ret_var.inner;
3779         if (ret_var.is_owned) {
3780                 ret_ref |= 1;
3781         }
3782         return ret_ref;
3783 }
3784
3785 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3786 CHECK(!owner->result_ok);
3787         return DecodeError_clone(&*owner->contents.err);
3788 }
3789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3790         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3791         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3792         int64_t ret_ref = 0;
3793         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3794         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3796         ret_ref = (uintptr_t)ret_var.inner;
3797         if (ret_var.is_owned) {
3798                 ret_ref |= 1;
3799         }
3800         return ret_ref;
3801 }
3802
3803 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3804 CHECK(owner->result_ok);
3805         return ChannelTypeFeatures_clone(&*owner->contents.result);
3806 }
3807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3808         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3809         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3810         int64_t ret_ref = 0;
3811         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3812         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3814         ret_ref = (uintptr_t)ret_var.inner;
3815         if (ret_var.is_owned) {
3816                 ret_ref |= 1;
3817         }
3818         return ret_ref;
3819 }
3820
3821 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3822 CHECK(!owner->result_ok);
3823         return DecodeError_clone(&*owner->contents.err);
3824 }
3825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3826         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3827         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3828         int64_t ret_ref = 0;
3829         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3830         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3832         ret_ref = (uintptr_t)ret_var.inner;
3833         if (ret_var.is_owned) {
3834                 ret_ref |= 1;
3835         }
3836         return ret_ref;
3837 }
3838
3839 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3840 CHECK(owner->result_ok);
3841         return NodeId_clone(&*owner->contents.result);
3842 }
3843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3844         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3845         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
3846         int64_t ret_ref = 0;
3847         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3848         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3850         ret_ref = (uintptr_t)ret_var.inner;
3851         if (ret_var.is_owned) {
3852                 ret_ref |= 1;
3853         }
3854         return ret_ref;
3855 }
3856
3857 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3858 CHECK(!owner->result_ok);
3859         return DecodeError_clone(&*owner->contents.err);
3860 }
3861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3862         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3863         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
3864         int64_t ret_ref = 0;
3865         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3866         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3868         ret_ref = (uintptr_t)ret_var.inner;
3869         if (ret_var.is_owned) {
3870                 ret_ref |= 1;
3871         }
3872         return ret_ref;
3873 }
3874
3875 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3876 CHECK(owner->result_ok);
3877         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
3878 }
3879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3880         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3881         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
3882         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
3883         int64_t ret_ref = (uintptr_t)ret_copy;
3884         return ret_ref;
3885 }
3886
3887 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3888 CHECK(!owner->result_ok);
3889         return DecodeError_clone(&*owner->contents.err);
3890 }
3891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3892         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3893         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_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 typedef struct LDKAccess_JCalls {
3906         atomic_size_t refcnt;
3907         JavaVM *vm;
3908         jweak o;
3909         jmethodID get_utxo_meth;
3910 } LDKAccess_JCalls;
3911 static void LDKAccess_JCalls_free(void* this_arg) {
3912         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3913         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3914                 JNIEnv *env;
3915                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3916                 if (get_jenv_res == JNI_EDETACHED) {
3917                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3918                 } else {
3919                         DO_ASSERT(get_jenv_res == JNI_OK);
3920                 }
3921                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3922                 if (get_jenv_res == JNI_EDETACHED) {
3923                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3924                 }
3925                 FREE(j_calls);
3926         }
3927 }
3928 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3929         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3930         JNIEnv *env;
3931         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3932         if (get_jenv_res == JNI_EDETACHED) {
3933                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3934         } else {
3935                 DO_ASSERT(get_jenv_res == JNI_OK);
3936         }
3937         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
3938         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
3939         int64_t short_channel_id_conv = short_channel_id;
3940         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3941         CHECK(obj != NULL);
3942         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id_conv);
3943         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3944                 (*env)->ExceptionDescribe(env);
3945                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
3946         }
3947         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3948         CHECK_ACCESS(ret_ptr);
3949         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
3950         FREE((void*)ret);
3951         if (get_jenv_res == JNI_EDETACHED) {
3952                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3953         }
3954         return ret_conv;
3955 }
3956 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
3957         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
3958         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3959 }
3960 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
3961         jclass c = (*env)->GetObjectClass(env, o);
3962         CHECK(c != NULL);
3963         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3964         atomic_init(&calls->refcnt, 1);
3965         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3966         calls->o = (*env)->NewWeakGlobalRef(env, o);
3967         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
3968         CHECK(calls->get_utxo_meth != NULL);
3969
3970         LDKAccess ret = {
3971                 .this_arg = (void*) calls,
3972                 .get_utxo = get_utxo_LDKAccess_jcall,
3973                 .free = LDKAccess_JCalls_free,
3974         };
3975         return ret;
3976 }
3977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
3978         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3979         *res_ptr = LDKAccess_init(env, clz, o);
3980         return (uint64_t)res_ptr;
3981 }
3982 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) {
3983         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3984         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3985         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
3986         unsigned char genesis_hash_arr[32];
3987         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
3988         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
3989         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3990         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3991         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3992         return (int64_t)ret_conv;
3993 }
3994
3995 static jclass LDKCOption_AccessZ_Some_class = NULL;
3996 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
3997 static jclass LDKCOption_AccessZ_None_class = NULL;
3998 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
3999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
4000         LDKCOption_AccessZ_Some_class =
4001                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
4002         CHECK(LDKCOption_AccessZ_Some_class != NULL);
4003         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
4004         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
4005         LDKCOption_AccessZ_None_class =
4006                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
4007         CHECK(LDKCOption_AccessZ_None_class != NULL);
4008         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
4009         CHECK(LDKCOption_AccessZ_None_meth != NULL);
4010 }
4011 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4012         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
4013         switch(obj->tag) {
4014                 case LDKCOption_AccessZ_Some: {
4015                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
4016                         *some_ret = obj->some;
4017                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
4018                         if ((*some_ret).free == LDKAccess_JCalls_free) {
4019                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
4020                                 LDKAccess_JCalls_cloned(&(*some_ret));
4021                         }
4022                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (int64_t)some_ret);
4023                 }
4024                 case LDKCOption_AccessZ_None: {
4025                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
4026                 }
4027                 default: abort();
4028         }
4029 }
4030 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4031 CHECK(owner->result_ok);
4032         return *owner->contents.result;
4033 }
4034 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4035         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
4036         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
4037         return ret_conv;
4038 }
4039
4040 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4041 CHECK(!owner->result_ok);
4042         return LightningError_clone(&*owner->contents.err);
4043 }
4044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4045         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
4046         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
4047         int64_t ret_ref = 0;
4048         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4049         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4050         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4051         ret_ref = (uintptr_t)ret_var.inner;
4052         if (ret_var.is_owned) {
4053                 ret_ref |= 1;
4054         }
4055         return ret_ref;
4056 }
4057
4058 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4059         return ChannelAnnouncement_clone(&owner->a);
4060 }
4061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4062         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
4063         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
4064         int64_t ret_ref = 0;
4065         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4066         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4068         ret_ref = (uintptr_t)ret_var.inner;
4069         if (ret_var.is_owned) {
4070                 ret_ref |= 1;
4071         }
4072         return ret_ref;
4073 }
4074
4075 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4076         return ChannelUpdate_clone(&owner->b);
4077 }
4078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4079         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
4080         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
4081         int64_t ret_ref = 0;
4082         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4083         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4085         ret_ref = (uintptr_t)ret_var.inner;
4086         if (ret_var.is_owned) {
4087                 ret_ref |= 1;
4088         }
4089         return ret_ref;
4090 }
4091
4092 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4093         return ChannelUpdate_clone(&owner->c);
4094 }
4095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
4096         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
4097         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
4098         int64_t ret_ref = 0;
4099         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4100         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4101         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4102         ret_ref = (uintptr_t)ret_var.inner;
4103         if (ret_var.is_owned) {
4104                 ret_ref |= 1;
4105         }
4106         return ret_ref;
4107 }
4108
4109 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
4110         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
4111         for (size_t i = 0; i < ret.datalen; i++) {
4112                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
4113         }
4114         return ret;
4115 }
4116 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
4117         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
4118         for (size_t i = 0; i < ret.datalen; i++) {
4119                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
4120         }
4121         return ret;
4122 }
4123 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4124 CHECK(owner->result_ok);
4125         return *owner->contents.result;
4126 }
4127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4128         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
4129         CResult_NoneLightningErrorZ_get_ok(owner_conv);
4130 }
4131
4132 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4133 CHECK(!owner->result_ok);
4134         return LightningError_clone(&*owner->contents.err);
4135 }
4136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4137         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
4138         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
4139         int64_t ret_ref = 0;
4140         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4141         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4143         ret_ref = (uintptr_t)ret_var.inner;
4144         if (ret_var.is_owned) {
4145                 ret_ref |= 1;
4146         }
4147         return ret_ref;
4148 }
4149
4150 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4151 CHECK(owner->result_ok);
4152         return ChannelUpdateInfo_clone(&*owner->contents.result);
4153 }
4154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4155         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
4156         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
4157         int64_t ret_ref = 0;
4158         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4159         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4161         ret_ref = (uintptr_t)ret_var.inner;
4162         if (ret_var.is_owned) {
4163                 ret_ref |= 1;
4164         }
4165         return ret_ref;
4166 }
4167
4168 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4169 CHECK(!owner->result_ok);
4170         return DecodeError_clone(&*owner->contents.err);
4171 }
4172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4173         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
4174         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
4175         int64_t ret_ref = 0;
4176         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4177         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4179         ret_ref = (uintptr_t)ret_var.inner;
4180         if (ret_var.is_owned) {
4181                 ret_ref |= 1;
4182         }
4183         return ret_ref;
4184 }
4185
4186 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4187 CHECK(owner->result_ok);
4188         return ChannelInfo_clone(&*owner->contents.result);
4189 }
4190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4191         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
4192         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
4193         int64_t ret_ref = 0;
4194         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4195         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4197         ret_ref = (uintptr_t)ret_var.inner;
4198         if (ret_var.is_owned) {
4199                 ret_ref |= 1;
4200         }
4201         return ret_ref;
4202 }
4203
4204 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4205 CHECK(!owner->result_ok);
4206         return DecodeError_clone(&*owner->contents.err);
4207 }
4208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4209         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
4210         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
4211         int64_t ret_ref = 0;
4212         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4213         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4215         ret_ref = (uintptr_t)ret_var.inner;
4216         if (ret_var.is_owned) {
4217                 ret_ref |= 1;
4218         }
4219         return ret_ref;
4220 }
4221
4222 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4223 CHECK(owner->result_ok);
4224         return RoutingFees_clone(&*owner->contents.result);
4225 }
4226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4227         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
4228         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
4229         int64_t ret_ref = 0;
4230         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4231         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4233         ret_ref = (uintptr_t)ret_var.inner;
4234         if (ret_var.is_owned) {
4235                 ret_ref |= 1;
4236         }
4237         return ret_ref;
4238 }
4239
4240 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4241 CHECK(!owner->result_ok);
4242         return DecodeError_clone(&*owner->contents.err);
4243 }
4244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4245         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
4246         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
4247         int64_t ret_ref = 0;
4248         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4249         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4250         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4251         ret_ref = (uintptr_t)ret_var.inner;
4252         if (ret_var.is_owned) {
4253                 ret_ref |= 1;
4254         }
4255         return ret_ref;
4256 }
4257
4258 static jclass LDKNetAddress_IPv4_class = NULL;
4259 static jmethodID LDKNetAddress_IPv4_meth = NULL;
4260 static jclass LDKNetAddress_IPv6_class = NULL;
4261 static jmethodID LDKNetAddress_IPv6_meth = NULL;
4262 static jclass LDKNetAddress_OnionV2_class = NULL;
4263 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
4264 static jclass LDKNetAddress_OnionV3_class = NULL;
4265 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
4266 static jclass LDKNetAddress_Hostname_class = NULL;
4267 static jmethodID LDKNetAddress_Hostname_meth = NULL;
4268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
4269         LDKNetAddress_IPv4_class =
4270                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
4271         CHECK(LDKNetAddress_IPv4_class != NULL);
4272         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
4273         CHECK(LDKNetAddress_IPv4_meth != NULL);
4274         LDKNetAddress_IPv6_class =
4275                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
4276         CHECK(LDKNetAddress_IPv6_class != NULL);
4277         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
4278         CHECK(LDKNetAddress_IPv6_meth != NULL);
4279         LDKNetAddress_OnionV2_class =
4280                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
4281         CHECK(LDKNetAddress_OnionV2_class != NULL);
4282         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
4283         CHECK(LDKNetAddress_OnionV2_meth != NULL);
4284         LDKNetAddress_OnionV3_class =
4285                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
4286         CHECK(LDKNetAddress_OnionV3_class != NULL);
4287         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
4288         CHECK(LDKNetAddress_OnionV3_meth != NULL);
4289         LDKNetAddress_Hostname_class =
4290                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$Hostname"));
4291         CHECK(LDKNetAddress_Hostname_class != NULL);
4292         LDKNetAddress_Hostname_meth = (*env)->GetMethodID(env, LDKNetAddress_Hostname_class, "<init>", "(JS)V");
4293         CHECK(LDKNetAddress_Hostname_meth != NULL);
4294 }
4295 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4296         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4297         switch(obj->tag) {
4298                 case LDKNetAddress_IPv4: {
4299                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
4300                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
4301                         int16_t port_conv = obj->i_pv4.port;
4302                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, port_conv);
4303                 }
4304                 case LDKNetAddress_IPv6: {
4305                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
4306                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
4307                         int16_t port_conv = obj->i_pv6.port;
4308                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, port_conv);
4309                 }
4310                 case LDKNetAddress_OnionV2: {
4311                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
4312                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
4313                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
4314                 }
4315                 case LDKNetAddress_OnionV3: {
4316                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
4317                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
4318                         int16_t checksum_conv = obj->onion_v3.checksum;
4319                         int8_t version_conv = obj->onion_v3.version;
4320                         int16_t port_conv = obj->onion_v3.port;
4321                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, checksum_conv, version_conv, port_conv);
4322                 }
4323                 case LDKNetAddress_Hostname: {
4324                         LDKHostname hostname_var = obj->hostname.hostname;
4325                         int64_t hostname_ref = 0;
4326                         CHECK((((uintptr_t)hostname_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4327                         CHECK((((uintptr_t)&hostname_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4328                         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_var);
4329                         hostname_ref = (uintptr_t)hostname_var.inner & ~1;
4330                         int16_t port_conv = obj->hostname.port;
4331                         return (*env)->NewObject(env, LDKNetAddress_Hostname_class, LDKNetAddress_Hostname_meth, hostname_ref, port_conv);
4332                 }
4333                 default: abort();
4334         }
4335 }
4336 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
4337         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
4338         for (size_t i = 0; i < ret.datalen; i++) {
4339                 ret.data[i] = NetAddress_clone(&orig->data[i]);
4340         }
4341         return ret;
4342 }
4343 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4344 CHECK(owner->result_ok);
4345         return NodeAnnouncementInfo_clone(&*owner->contents.result);
4346 }
4347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4348         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
4349         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
4350         int64_t ret_ref = 0;
4351         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4352         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4354         ret_ref = (uintptr_t)ret_var.inner;
4355         if (ret_var.is_owned) {
4356                 ret_ref |= 1;
4357         }
4358         return ret_ref;
4359 }
4360
4361 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4362 CHECK(!owner->result_ok);
4363         return DecodeError_clone(&*owner->contents.err);
4364 }
4365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4366         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
4367         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
4368         int64_t ret_ref = 0;
4369         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4370         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4372         ret_ref = (uintptr_t)ret_var.inner;
4373         if (ret_var.is_owned) {
4374                 ret_ref |= 1;
4375         }
4376         return ret_ref;
4377 }
4378
4379 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4380 CHECK(owner->result_ok);
4381         return NodeAlias_clone(&*owner->contents.result);
4382 }
4383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4384         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
4385         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
4386         int64_t ret_ref = 0;
4387         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4388         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4390         ret_ref = (uintptr_t)ret_var.inner;
4391         if (ret_var.is_owned) {
4392                 ret_ref |= 1;
4393         }
4394         return ret_ref;
4395 }
4396
4397 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4398 CHECK(!owner->result_ok);
4399         return DecodeError_clone(&*owner->contents.err);
4400 }
4401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4402         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
4403         LDKDecodeError ret_var = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
4404         int64_t ret_ref = 0;
4405         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4406         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4408         ret_ref = (uintptr_t)ret_var.inner;
4409         if (ret_var.is_owned) {
4410                 ret_ref |= 1;
4411         }
4412         return ret_ref;
4413 }
4414
4415 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4416 CHECK(owner->result_ok);
4417         return NodeInfo_clone(&*owner->contents.result);
4418 }
4419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4420         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
4421         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
4422         int64_t ret_ref = 0;
4423         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4424         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4426         ret_ref = (uintptr_t)ret_var.inner;
4427         if (ret_var.is_owned) {
4428                 ret_ref |= 1;
4429         }
4430         return ret_ref;
4431 }
4432
4433 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4434 CHECK(!owner->result_ok);
4435         return DecodeError_clone(&*owner->contents.err);
4436 }
4437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4438         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
4439         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
4440         int64_t ret_ref = 0;
4441         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4442         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4444         ret_ref = (uintptr_t)ret_var.inner;
4445         if (ret_var.is_owned) {
4446                 ret_ref |= 1;
4447         }
4448         return ret_ref;
4449 }
4450
4451 static inline struct LDKNetworkGraph *CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4452 CHECK(owner->result_ok);
4453         return &*owner->contents.result;
4454 }
4455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4456         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
4457         LDKNetworkGraph ret_var = *CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
4458         int64_t ret_ref = 0;
4459         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4460         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4462         ret_ref = (uintptr_t)ret_var.inner & ~1;
4463         return ret_ref;
4464 }
4465
4466 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4467 CHECK(!owner->result_ok);
4468         return DecodeError_clone(&*owner->contents.err);
4469 }
4470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4471         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
4472         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
4473         int64_t ret_ref = 0;
4474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4477         ret_ref = (uintptr_t)ret_var.inner;
4478         if (ret_var.is_owned) {
4479                 ret_ref |= 1;
4480         }
4481         return ret_ref;
4482 }
4483
4484 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
4485 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
4486 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
4487 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
4488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
4489         LDKCOption_CVec_NetAddressZZ_Some_class =
4490                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
4491         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
4492         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
4493         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
4494         LDKCOption_CVec_NetAddressZZ_None_class =
4495                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
4496         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
4497         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
4498         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
4499 }
4500 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4501         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
4502         switch(obj->tag) {
4503                 case LDKCOption_CVec_NetAddressZZ_Some: {
4504                         LDKCVec_NetAddressZ some_var = obj->some;
4505                         int64_tArray some_arr = NULL;
4506                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
4507                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
4508                         for (size_t m = 0; m < some_var.datalen; m++) {
4509                                 int64_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
4510                                 some_arr_ptr[m] = some_conv_12_ref;
4511                         }
4512                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
4513                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
4514                 }
4515                 case LDKCOption_CVec_NetAddressZZ_None: {
4516                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
4517                 }
4518                 default: abort();
4519         }
4520 }
4521 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4522 CHECK(owner->result_ok);
4523         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
4524 }
4525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4526         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4527         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4528         int64_t ret_ref = 0;
4529         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4530         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4532         ret_ref = (uintptr_t)ret_var.inner;
4533         if (ret_var.is_owned) {
4534                 ret_ref |= 1;
4535         }
4536         return ret_ref;
4537 }
4538
4539 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4540 CHECK(!owner->result_ok);
4541         return DecodeError_clone(&*owner->contents.err);
4542 }
4543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4544         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4545         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4546         int64_t ret_ref = 0;
4547         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4548         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4550         ret_ref = (uintptr_t)ret_var.inner;
4551         if (ret_var.is_owned) {
4552                 ret_ref |= 1;
4553         }
4554         return ret_ref;
4555 }
4556
4557 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4558 CHECK(owner->result_ok);
4559         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
4560 }
4561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4562         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4563         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4564         int64_t ret_ref = 0;
4565         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4566         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4567         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4568         ret_ref = (uintptr_t)ret_var.inner;
4569         if (ret_var.is_owned) {
4570                 ret_ref |= 1;
4571         }
4572         return ret_ref;
4573 }
4574
4575 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4576 CHECK(!owner->result_ok);
4577         return DecodeError_clone(&*owner->contents.err);
4578 }
4579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4580         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4581         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4582         int64_t ret_ref = 0;
4583         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4584         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4586         ret_ref = (uintptr_t)ret_var.inner;
4587         if (ret_var.is_owned) {
4588                 ret_ref |= 1;
4589         }
4590         return ret_ref;
4591 }
4592
4593 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4594 CHECK(owner->result_ok);
4595         return SpendableOutputDescriptor_clone(&*owner->contents.result);
4596 }
4597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4598         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
4599         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
4600         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4601         int64_t ret_ref = (uintptr_t)ret_copy;
4602         return ret_ref;
4603 }
4604
4605 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4606 CHECK(!owner->result_ok);
4607         return DecodeError_clone(&*owner->contents.err);
4608 }
4609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4610         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
4611         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4612         int64_t ret_ref = 0;
4613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4616         ret_ref = (uintptr_t)ret_var.inner;
4617         if (ret_var.is_owned) {
4618                 ret_ref |= 1;
4619         }
4620         return ret_ref;
4621 }
4622
4623 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
4624         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
4625         for (size_t i = 0; i < ret.datalen; i++) {
4626                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
4627         }
4628         return ret;
4629 }
4630 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4631         return owner->a;
4632 }
4633 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4634         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
4635         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4636         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
4637         return ret_arr;
4638 }
4639
4640 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4641         return owner->b;
4642 }
4643 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4644         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
4645         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
4646         jobjectArray ret_arr = NULL;
4647         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
4648         ;
4649         for (size_t i = 0; i < ret_var.datalen; i++) {
4650                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
4651                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
4652                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
4653         }
4654         
4655         return ret_arr;
4656 }
4657
4658 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
4659 CHECK(owner->result_ok);
4660         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
4661 }
4662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4663         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
4664         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
4665         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
4666         return ((int64_t)ret_conv);
4667 }
4668
4669 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
4670 CHECK(!owner->result_ok);
4671         return *owner->contents.err;
4672 }
4673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4674         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
4675         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
4676 }
4677
4678 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
4679 CHECK(owner->result_ok);
4680         return *owner->contents.result;
4681 }
4682 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4683         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
4684         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4685         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
4686         return ret_arr;
4687 }
4688
4689 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
4690 CHECK(!owner->result_ok);
4691         return *owner->contents.err;
4692 }
4693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4694         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
4695         CResult_SignatureNoneZ_get_err(owner_conv);
4696 }
4697
4698 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
4699         return owner->a;
4700 }
4701 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4702         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
4703         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4704         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form);
4705         return ret_arr;
4706 }
4707
4708 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
4709         return owner->b;
4710 }
4711 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4712         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
4713         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4714         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form);
4715         return ret_arr;
4716 }
4717
4718 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
4719 CHECK(owner->result_ok);
4720         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
4721 }
4722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4723         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
4724         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
4725         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
4726         return ((int64_t)ret_conv);
4727 }
4728
4729 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
4730 CHECK(!owner->result_ok);
4731         return *owner->contents.err;
4732 }
4733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4734         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
4735         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
4736 }
4737
4738 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
4739 CHECK(owner->result_ok);
4740         return *owner->contents.result;
4741 }
4742 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4743         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
4744         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4745         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes);
4746         return ret_arr;
4747 }
4748
4749 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
4750 CHECK(!owner->result_ok);
4751         return *owner->contents.err;
4752 }
4753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4754         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
4755         CResult_SecretKeyNoneZ_get_err(owner_conv);
4756 }
4757
4758 typedef struct LDKBaseSign_JCalls {
4759         atomic_size_t refcnt;
4760         JavaVM *vm;
4761         jweak o;
4762         jmethodID get_per_commitment_point_meth;
4763         jmethodID release_commitment_secret_meth;
4764         jmethodID validate_holder_commitment_meth;
4765         jmethodID channel_keys_id_meth;
4766         jmethodID sign_counterparty_commitment_meth;
4767         jmethodID validate_counterparty_revocation_meth;
4768         jmethodID sign_holder_commitment_and_htlcs_meth;
4769         jmethodID sign_justice_revoked_output_meth;
4770         jmethodID sign_justice_revoked_htlc_meth;
4771         jmethodID sign_counterparty_htlc_transaction_meth;
4772         jmethodID sign_closing_transaction_meth;
4773         jmethodID sign_channel_announcement_meth;
4774         jmethodID ready_channel_meth;
4775 } LDKBaseSign_JCalls;
4776 static void LDKBaseSign_JCalls_free(void* this_arg) {
4777         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4778         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4779                 JNIEnv *env;
4780                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4781                 if (get_jenv_res == JNI_EDETACHED) {
4782                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4783                 } else {
4784                         DO_ASSERT(get_jenv_res == JNI_OK);
4785                 }
4786                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4787                 if (get_jenv_res == JNI_EDETACHED) {
4788                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4789                 }
4790                 FREE(j_calls);
4791         }
4792 }
4793 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
4794         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4795         JNIEnv *env;
4796         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4797         if (get_jenv_res == JNI_EDETACHED) {
4798                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4799         } else {
4800                 DO_ASSERT(get_jenv_res == JNI_OK);
4801         }
4802         int64_t idx_conv = idx;
4803         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4804         CHECK(obj != NULL);
4805         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx_conv);
4806         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4807                 (*env)->ExceptionDescribe(env);
4808                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
4809         }
4810         LDKPublicKey ret_ref;
4811         CHECK((*env)->GetArrayLength(env, ret) == 33);
4812         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
4813         if (get_jenv_res == JNI_EDETACHED) {
4814                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4815         }
4816         return ret_ref;
4817 }
4818 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
4819         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4820         JNIEnv *env;
4821         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4822         if (get_jenv_res == JNI_EDETACHED) {
4823                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4824         } else {
4825                 DO_ASSERT(get_jenv_res == JNI_OK);
4826         }
4827         int64_t idx_conv = idx;
4828         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4829         CHECK(obj != NULL);
4830         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx_conv);
4831         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4832                 (*env)->ExceptionDescribe(env);
4833                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
4834         }
4835         LDKThirtyTwoBytes ret_ref;
4836         CHECK((*env)->GetArrayLength(env, ret) == 32);
4837         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4838         if (get_jenv_res == JNI_EDETACHED) {
4839                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4840         }
4841         return ret_ref;
4842 }
4843 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
4844         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4845         JNIEnv *env;
4846         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4847         if (get_jenv_res == JNI_EDETACHED) {
4848                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4849         } else {
4850                 DO_ASSERT(get_jenv_res == JNI_OK);
4851         }
4852         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
4853         int64_t holder_tx_ref = 0;
4854         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
4855         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4856         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4857         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
4858         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
4859         if (holder_tx_var.is_owned) {
4860                 holder_tx_ref |= 1;
4861         }
4862         LDKCVec_PaymentPreimageZ preimages_var = preimages;
4863         jobjectArray preimages_arr = NULL;
4864         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
4865         ;
4866         for (size_t i = 0; i < preimages_var.datalen; i++) {
4867                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
4868                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
4869                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
4870         }
4871         
4872         FREE(preimages_var.data);
4873         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4874         CHECK(obj != NULL);
4875         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
4876         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4877                 (*env)->ExceptionDescribe(env);
4878                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
4879         }
4880         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4881         CHECK_ACCESS(ret_ptr);
4882         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4883         FREE((void*)ret);
4884         if (get_jenv_res == JNI_EDETACHED) {
4885                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4886         }
4887         return ret_conv;
4888 }
4889 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
4890         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4891         JNIEnv *env;
4892         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4893         if (get_jenv_res == JNI_EDETACHED) {
4894                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4895         } else {
4896                 DO_ASSERT(get_jenv_res == JNI_OK);
4897         }
4898         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4899         CHECK(obj != NULL);
4900         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
4901         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4902                 (*env)->ExceptionDescribe(env);
4903                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
4904         }
4905         LDKThirtyTwoBytes ret_ref;
4906         CHECK((*env)->GetArrayLength(env, ret) == 32);
4907         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4908         if (get_jenv_res == JNI_EDETACHED) {
4909                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4910         }
4911         return ret_ref;
4912 }
4913 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
4914         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4915         JNIEnv *env;
4916         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4917         if (get_jenv_res == JNI_EDETACHED) {
4918                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4919         } else {
4920                 DO_ASSERT(get_jenv_res == JNI_OK);
4921         }
4922         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
4923         int64_t commitment_tx_ref = 0;
4924         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
4925         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4926         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4927         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
4928         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
4929         if (commitment_tx_var.is_owned) {
4930                 commitment_tx_ref |= 1;
4931         }
4932         LDKCVec_PaymentPreimageZ preimages_var = preimages;
4933         jobjectArray preimages_arr = NULL;
4934         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
4935         ;
4936         for (size_t i = 0; i < preimages_var.datalen; i++) {
4937                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
4938                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
4939                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
4940         }
4941         
4942         FREE(preimages_var.data);
4943         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4944         CHECK(obj != NULL);
4945         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
4946         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4947                 (*env)->ExceptionDescribe(env);
4948                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
4949         }
4950         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4951         CHECK_ACCESS(ret_ptr);
4952         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
4953         FREE((void*)ret);
4954         if (get_jenv_res == JNI_EDETACHED) {
4955                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4956         }
4957         return ret_conv;
4958 }
4959 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
4960         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4961         JNIEnv *env;
4962         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4963         if (get_jenv_res == JNI_EDETACHED) {
4964                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4965         } else {
4966                 DO_ASSERT(get_jenv_res == JNI_OK);
4967         }
4968         int64_t idx_conv = idx;
4969         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
4970         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
4971         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4972         CHECK(obj != NULL);
4973         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx_conv, secret_arr);
4974         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4975                 (*env)->ExceptionDescribe(env);
4976                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
4977         }
4978         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4979         CHECK_ACCESS(ret_ptr);
4980         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4981         FREE((void*)ret);
4982         if (get_jenv_res == JNI_EDETACHED) {
4983                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4984         }
4985         return ret_conv;
4986 }
4987 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
4988         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4989         JNIEnv *env;
4990         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4991         if (get_jenv_res == JNI_EDETACHED) {
4992                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4993         } else {
4994                 DO_ASSERT(get_jenv_res == JNI_OK);
4995         }
4996         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
4997         int64_t commitment_tx_ref = 0;
4998         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
4999         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5000         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5001         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
5002         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
5003         if (commitment_tx_var.is_owned) {
5004                 commitment_tx_ref |= 1;
5005         }
5006         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5007         CHECK(obj != NULL);
5008         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
5009         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5010                 (*env)->ExceptionDescribe(env);
5011                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
5012         }
5013         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5014         CHECK_ACCESS(ret_ptr);
5015         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
5016         FREE((void*)ret);
5017         if (get_jenv_res == JNI_EDETACHED) {
5018                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5019         }
5020         return ret_conv;
5021 }
5022 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]) {
5023         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5024         JNIEnv *env;
5025         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5026         if (get_jenv_res == JNI_EDETACHED) {
5027                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5028         } else {
5029                 DO_ASSERT(get_jenv_res == JNI_OK);
5030         }
5031         LDKTransaction justice_tx_var = justice_tx;
5032         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
5033         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
5034         Transaction_free(justice_tx_var);
5035         int64_t input_conv = input;
5036         int64_t amount_conv = amount;
5037         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
5038         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
5039         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5040         CHECK(obj != NULL);
5041         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);
5042         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5043                 (*env)->ExceptionDescribe(env);
5044                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
5045         }
5046         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5047         CHECK_ACCESS(ret_ptr);
5048         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5049         FREE((void*)ret);
5050         if (get_jenv_res == JNI_EDETACHED) {
5051                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5052         }
5053         return ret_conv;
5054 }
5055 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) {
5056         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5057         JNIEnv *env;
5058         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5059         if (get_jenv_res == JNI_EDETACHED) {
5060                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5061         } else {
5062                 DO_ASSERT(get_jenv_res == JNI_OK);
5063         }
5064         LDKTransaction justice_tx_var = justice_tx;
5065         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
5066         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
5067         Transaction_free(justice_tx_var);
5068         int64_t input_conv = input;
5069         int64_t amount_conv = amount;
5070         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
5071         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
5072         LDKHTLCOutputInCommitment htlc_var = *htlc;
5073         int64_t htlc_ref = 0;
5074         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
5075         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5076         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5077         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
5078         htlc_ref = (uintptr_t)htlc_var.inner;
5079         if (htlc_var.is_owned) {
5080                 htlc_ref |= 1;
5081         }
5082         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5083         CHECK(obj != NULL);
5084         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);
5085         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5086                 (*env)->ExceptionDescribe(env);
5087                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
5088         }
5089         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5090         CHECK_ACCESS(ret_ptr);
5091         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5092         FREE((void*)ret);
5093         if (get_jenv_res == JNI_EDETACHED) {
5094                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5095         }
5096         return ret_conv;
5097 }
5098 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) {
5099         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5100         JNIEnv *env;
5101         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5102         if (get_jenv_res == JNI_EDETACHED) {
5103                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5104         } else {
5105                 DO_ASSERT(get_jenv_res == JNI_OK);
5106         }
5107         LDKTransaction htlc_tx_var = htlc_tx;
5108         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
5109         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
5110         Transaction_free(htlc_tx_var);
5111         int64_t input_conv = input;
5112         int64_t amount_conv = amount;
5113         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
5114         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
5115         LDKHTLCOutputInCommitment htlc_var = *htlc;
5116         int64_t htlc_ref = 0;
5117         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
5118         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5119         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5120         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
5121         htlc_ref = (uintptr_t)htlc_var.inner;
5122         if (htlc_var.is_owned) {
5123                 htlc_ref |= 1;
5124         }
5125         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5126         CHECK(obj != NULL);
5127         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);
5128         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5129                 (*env)->ExceptionDescribe(env);
5130                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
5131         }
5132         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5133         CHECK_ACCESS(ret_ptr);
5134         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5135         FREE((void*)ret);
5136         if (get_jenv_res == JNI_EDETACHED) {
5137                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5138         }
5139         return ret_conv;
5140 }
5141 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
5142         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5143         JNIEnv *env;
5144         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5145         if (get_jenv_res == JNI_EDETACHED) {
5146                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5147         } else {
5148                 DO_ASSERT(get_jenv_res == JNI_OK);
5149         }
5150         LDKClosingTransaction closing_tx_var = *closing_tx;
5151         int64_t closing_tx_ref = 0;
5152         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
5153         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5154         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5155         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
5156         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
5157         if (closing_tx_var.is_owned) {
5158                 closing_tx_ref |= 1;
5159         }
5160         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5161         CHECK(obj != NULL);
5162         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
5163         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5164                 (*env)->ExceptionDescribe(env);
5165                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
5166         }
5167         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5168         CHECK_ACCESS(ret_ptr);
5169         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5170         FREE((void*)ret);
5171         if (get_jenv_res == JNI_EDETACHED) {
5172                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5173         }
5174         return ret_conv;
5175 }
5176 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
5177         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5178         JNIEnv *env;
5179         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5180         if (get_jenv_res == JNI_EDETACHED) {
5181                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5182         } else {
5183                 DO_ASSERT(get_jenv_res == JNI_OK);
5184         }
5185         LDKUnsignedChannelAnnouncement msg_var = *msg;
5186         int64_t msg_ref = 0;
5187         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
5188         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5189         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5190         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
5191         msg_ref = (uintptr_t)msg_var.inner;
5192         if (msg_var.is_owned) {
5193                 msg_ref |= 1;
5194         }
5195         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5196         CHECK(obj != NULL);
5197         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
5198         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5199                 (*env)->ExceptionDescribe(env);
5200                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
5201         }
5202         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5203         CHECK_ACCESS(ret_ptr);
5204         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
5205         FREE((void*)ret);
5206         if (get_jenv_res == JNI_EDETACHED) {
5207                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5208         }
5209         return ret_conv;
5210 }
5211 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
5212         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5213         JNIEnv *env;
5214         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5215         if (get_jenv_res == JNI_EDETACHED) {
5216                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5217         } else {
5218                 DO_ASSERT(get_jenv_res == JNI_OK);
5219         }
5220         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
5221         int64_t channel_parameters_ref = 0;
5222         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
5223         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5224         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5225         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
5226         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
5227         if (channel_parameters_var.is_owned) {
5228                 channel_parameters_ref |= 1;
5229         }
5230         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5231         CHECK(obj != NULL);
5232         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
5233         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5234                 (*env)->ExceptionDescribe(env);
5235                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
5236         }
5237         if (get_jenv_res == JNI_EDETACHED) {
5238                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5239         }
5240 }
5241 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5242         jclass c = (*env)->GetObjectClass(env, o);
5243         CHECK(c != NULL);
5244         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
5245         atomic_init(&calls->refcnt, 1);
5246         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5247         calls->o = (*env)->NewWeakGlobalRef(env, o);
5248         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
5249         CHECK(calls->get_per_commitment_point_meth != NULL);
5250         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
5251         CHECK(calls->release_commitment_secret_meth != NULL);
5252         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
5253         CHECK(calls->validate_holder_commitment_meth != NULL);
5254         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
5255         CHECK(calls->channel_keys_id_meth != NULL);
5256         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
5257         CHECK(calls->sign_counterparty_commitment_meth != NULL);
5258         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
5259         CHECK(calls->validate_counterparty_revocation_meth != NULL);
5260         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
5261         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
5262         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
5263         CHECK(calls->sign_justice_revoked_output_meth != NULL);
5264         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
5265         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
5266         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
5267         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
5268         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
5269         CHECK(calls->sign_closing_transaction_meth != NULL);
5270         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
5271         CHECK(calls->sign_channel_announcement_meth != NULL);
5272         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
5273         CHECK(calls->ready_channel_meth != NULL);
5274
5275         LDKChannelPublicKeys pubkeys_conv;
5276         pubkeys_conv.inner = (void*)(pubkeys & (~1));
5277         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
5278         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5279
5280         LDKBaseSign ret = {
5281                 .this_arg = (void*) calls,
5282                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
5283                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
5284                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
5285                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
5286                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
5287                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
5288                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
5289                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
5290                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
5291                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
5292                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
5293                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
5294                 .ready_channel = ready_channel_LDKBaseSign_jcall,
5295                 .free = LDKBaseSign_JCalls_free,
5296                 .pubkeys = pubkeys_conv,
5297                 .set_pubkeys = NULL,
5298         };
5299         return ret;
5300 }
5301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5302         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
5303         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
5304         return (uint64_t)res_ptr;
5305 }
5306 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) {
5307         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5308         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5309         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5310         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5311         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
5312         return ret_arr;
5313 }
5314
5315 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
5316         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5317         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5318         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5319         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5320         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
5321         return ret_arr;
5322 }
5323
5324 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) {
5325         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5326         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5327         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5328         LDKHolderCommitmentTransaction holder_tx_conv;
5329         holder_tx_conv.inner = (void*)(holder_tx & (~1));
5330         holder_tx_conv.is_owned = false;
5331         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
5332         LDKCVec_PaymentPreimageZ preimages_constr;
5333         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5334         if (preimages_constr.datalen > 0)
5335                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5336         else
5337                 preimages_constr.data = NULL;
5338         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5339                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5340                 LDKThirtyTwoBytes preimages_conv_8_ref;
5341                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5342                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5343                 preimages_constr.data[i] = preimages_conv_8_ref;
5344         }
5345         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5346         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
5347         return (int64_t)ret_conv;
5348 }
5349
5350 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
5351         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5352         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5353         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5354         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5355         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
5356         return ret_arr;
5357 }
5358
5359 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) {
5360         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5361         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5362         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5363         LDKCommitmentTransaction commitment_tx_conv;
5364         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
5365         commitment_tx_conv.is_owned = false;
5366         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5367         LDKCVec_PaymentPreimageZ preimages_constr;
5368         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5369         if (preimages_constr.datalen > 0)
5370                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5371         else
5372                 preimages_constr.data = NULL;
5373         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5374                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5375                 LDKThirtyTwoBytes preimages_conv_8_ref;
5376                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5377                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5378                 preimages_constr.data[i] = preimages_conv_8_ref;
5379         }
5380         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5381         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
5382         return (int64_t)ret_conv;
5383 }
5384
5385 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) {
5386         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5387         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5388         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5389         unsigned char secret_arr[32];
5390         CHECK((*env)->GetArrayLength(env, secret) == 32);
5391         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
5392         unsigned char (*secret_ref)[32] = &secret_arr;
5393         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5394         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
5395         return (int64_t)ret_conv;
5396 }
5397
5398 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) {
5399         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5400         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5401         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5402         LDKHolderCommitmentTransaction commitment_tx_conv;
5403         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
5404         commitment_tx_conv.is_owned = false;
5405         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5406         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5407         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
5408         return (int64_t)ret_conv;
5409 }
5410
5411 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) {
5412         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5413         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5414         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5415         LDKTransaction justice_tx_ref;
5416         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5417         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5418         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5419         justice_tx_ref.data_is_owned = true;
5420         unsigned char per_commitment_key_arr[32];
5421         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5422         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5423         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5424         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5425         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
5426         return (int64_t)ret_conv;
5427 }
5428
5429 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) {
5430         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5431         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5432         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5433         LDKTransaction justice_tx_ref;
5434         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5435         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5436         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5437         justice_tx_ref.data_is_owned = true;
5438         unsigned char per_commitment_key_arr[32];
5439         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5440         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5441         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5442         LDKHTLCOutputInCommitment htlc_conv;
5443         htlc_conv.inner = (void*)(htlc & (~1));
5444         htlc_conv.is_owned = false;
5445         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5446         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5447         *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);
5448         return (int64_t)ret_conv;
5449 }
5450
5451 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) {
5452         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5453         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5454         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5455         LDKTransaction htlc_tx_ref;
5456         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
5457         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
5458         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
5459         htlc_tx_ref.data_is_owned = true;
5460         LDKPublicKey per_commitment_point_ref;
5461         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
5462         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
5463         LDKHTLCOutputInCommitment htlc_conv;
5464         htlc_conv.inner = (void*)(htlc & (~1));
5465         htlc_conv.is_owned = false;
5466         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5467         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5468         *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);
5469         return (int64_t)ret_conv;
5470 }
5471
5472 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) {
5473         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5474         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5475         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5476         LDKClosingTransaction closing_tx_conv;
5477         closing_tx_conv.inner = (void*)(closing_tx & (~1));
5478         closing_tx_conv.is_owned = false;
5479         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
5480         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5481         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
5482         return (int64_t)ret_conv;
5483 }
5484
5485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
5486         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5487         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5488         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5489         LDKUnsignedChannelAnnouncement msg_conv;
5490         msg_conv.inner = (void*)(msg & (~1));
5491         msg_conv.is_owned = false;
5492         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
5493         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
5494         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
5495         return (int64_t)ret_conv;
5496 }
5497
5498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
5499         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5500         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5501         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5502         LDKChannelTransactionParameters channel_parameters_conv;
5503         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
5504         channel_parameters_conv.is_owned = false;
5505         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
5506         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
5507 }
5508
5509 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
5510         if (this_arg->set_pubkeys != NULL)
5511                 this_arg->set_pubkeys(this_arg);
5512         return this_arg->pubkeys;
5513 }
5514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
5515         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5516         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5517         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5518         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
5519         int64_t ret_ref = 0;
5520         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5521         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5522         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5523         ret_ref = (uintptr_t)ret_var.inner;
5524         if (ret_var.is_owned) {
5525                 ret_ref |= 1;
5526         }
5527         return ret_ref;
5528 }
5529
5530 typedef struct LDKSign_JCalls {
5531         atomic_size_t refcnt;
5532         JavaVM *vm;
5533         jweak o;
5534         LDKBaseSign_JCalls* BaseSign;
5535         jmethodID write_meth;
5536 } LDKSign_JCalls;
5537 static void LDKSign_JCalls_free(void* this_arg) {
5538         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5539         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5540                 JNIEnv *env;
5541                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5542                 if (get_jenv_res == JNI_EDETACHED) {
5543                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5544                 } else {
5545                         DO_ASSERT(get_jenv_res == JNI_OK);
5546                 }
5547                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5548                 if (get_jenv_res == JNI_EDETACHED) {
5549                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5550                 }
5551                 FREE(j_calls);
5552         }
5553 }
5554 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
5555         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5556         JNIEnv *env;
5557         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5558         if (get_jenv_res == JNI_EDETACHED) {
5559                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5560         } else {
5561                 DO_ASSERT(get_jenv_res == JNI_OK);
5562         }
5563         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5564         CHECK(obj != NULL);
5565         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
5566         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5567                 (*env)->ExceptionDescribe(env);
5568                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
5569         }
5570         LDKCVec_u8Z ret_ref;
5571         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5572         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5573         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5574         if (get_jenv_res == JNI_EDETACHED) {
5575                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5576         }
5577         return ret_ref;
5578 }
5579 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
5580         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
5581         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5582         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
5583 }
5584 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
5585         jclass c = (*env)->GetObjectClass(env, o);
5586         CHECK(c != NULL);
5587         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
5588         atomic_init(&calls->refcnt, 1);
5589         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5590         calls->o = (*env)->NewWeakGlobalRef(env, o);
5591         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
5592         CHECK(calls->write_meth != NULL);
5593
5594         LDKChannelPublicKeys pubkeys_conv;
5595         pubkeys_conv.inner = (void*)(pubkeys & (~1));
5596         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
5597         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5598
5599         LDKSign ret = {
5600                 .this_arg = (void*) calls,
5601                 .write = write_LDKSign_jcall,
5602                 .cloned = LDKSign_JCalls_cloned,
5603                 .free = LDKSign_JCalls_free,
5604                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
5605         };
5606         calls->BaseSign = ret.BaseSign.this_arg;
5607         return ret;
5608 }
5609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
5610         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
5611         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
5612         return (uint64_t)res_ptr;
5613 }
5614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
5615         LDKSign *inp = (LDKSign *)(arg & ~1);
5616         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
5617         DO_ASSERT((res_ptr & 1) == 0);
5618         return (int64_t)(res_ptr | 1);
5619 }
5620 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
5621         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5622         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5623         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
5624         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5625         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5626         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5627         CVec_u8Z_free(ret_var);
5628         return ret_arr;
5629 }
5630
5631 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5632 CHECK(owner->result_ok);
5633         return Sign_clone(&*owner->contents.result);
5634 }
5635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5636         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
5637         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5638         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
5639         return (int64_t)ret_ret;
5640 }
5641
5642 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5643 CHECK(!owner->result_ok);
5644         return DecodeError_clone(&*owner->contents.err);
5645 }
5646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5647         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
5648         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
5649         int64_t ret_ref = 0;
5650         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5651         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5653         ret_ref = (uintptr_t)ret_var.inner;
5654         if (ret_var.is_owned) {
5655                 ret_ref |= 1;
5656         }
5657         return ret_ref;
5658 }
5659
5660 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5661 CHECK(owner->result_ok);
5662         return *owner->contents.result;
5663 }
5664 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5665         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
5666         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
5667         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
5668         return ret_arr;
5669 }
5670
5671 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5672 CHECK(!owner->result_ok);
5673         return *owner->contents.err;
5674 }
5675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5676         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
5677         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
5678 }
5679
5680 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
5681         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
5682         for (size_t i = 0; i < ret.datalen; i++) {
5683                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
5684         }
5685         return ret;
5686 }
5687 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5688 CHECK(owner->result_ok);
5689         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
5690 }
5691 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5692         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
5693         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
5694         jobjectArray ret_arr = NULL;
5695         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
5696         ;
5697         for (size_t i = 0; i < ret_var.datalen; i++) {
5698                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
5699                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
5700                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
5701                 CVec_u8Z_free(ret_conv_8_var);
5702                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
5703         }
5704         
5705         FREE(ret_var.data);
5706         return ret_arr;
5707 }
5708
5709 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5710 CHECK(!owner->result_ok);
5711         return *owner->contents.err;
5712 }
5713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5714         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
5715         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
5716 }
5717
5718 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5719 CHECK(owner->result_ok);
5720         return InMemorySigner_clone(&*owner->contents.result);
5721 }
5722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5723         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
5724         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
5725         int64_t ret_ref = 0;
5726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5729         ret_ref = (uintptr_t)ret_var.inner;
5730         if (ret_var.is_owned) {
5731                 ret_ref |= 1;
5732         }
5733         return ret_ref;
5734 }
5735
5736 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5737 CHECK(!owner->result_ok);
5738         return DecodeError_clone(&*owner->contents.err);
5739 }
5740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5741         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
5742         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
5743         int64_t ret_ref = 0;
5744         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5745         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5747         ret_ref = (uintptr_t)ret_var.inner;
5748         if (ret_var.is_owned) {
5749                 ret_ref |= 1;
5750         }
5751         return ret_ref;
5752 }
5753
5754 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
5755         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
5756         for (size_t i = 0; i < ret.datalen; i++) {
5757                 ret.data[i] = TxOut_clone(&orig->data[i]);
5758         }
5759         return ret;
5760 }
5761 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5762 CHECK(owner->result_ok);
5763         return *owner->contents.result;
5764 }
5765 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5766         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
5767         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
5768         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5769         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5770         return ret_arr;
5771 }
5772
5773 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5774 CHECK(!owner->result_ok);
5775         return *owner->contents.err;
5776 }
5777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5778         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
5779         CResult_TransactionNoneZ_get_err(owner_conv);
5780 }
5781
5782 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5783         return ThirtyTwoBytes_clone(&owner->a);
5784 }
5785 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5786         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5787         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5788         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
5789         return ret_arr;
5790 }
5791
5792 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5793         return ChannelMonitor_clone(&owner->b);
5794 }
5795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5796         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5797         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
5798         int64_t ret_ref = 0;
5799         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5800         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5801         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5802         ret_ref = (uintptr_t)ret_var.inner;
5803         if (ret_var.is_owned) {
5804                 ret_ref |= 1;
5805         }
5806         return ret_ref;
5807 }
5808
5809 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
5810         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
5811         for (size_t i = 0; i < ret.datalen; i++) {
5812                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
5813         }
5814         return ret;
5815 }
5816 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
5817 CHECK(owner->result_ok);
5818         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
5819 }
5820 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5821         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
5822         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
5823         int64_tArray ret_arr = NULL;
5824         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5825         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5826         for (size_t j = 0; j < ret_var.datalen; j++) {
5827                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5828                 *ret_conv_35_conv = ret_var.data[j];
5829                 ret_arr_ptr[j] = ((int64_t)ret_conv_35_conv);
5830         }
5831         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5832         FREE(ret_var.data);
5833         return ret_arr;
5834 }
5835
5836 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
5837 CHECK(!owner->result_ok);
5838         return *owner->contents.err;
5839 }
5840 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5841         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
5842         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
5843         return ret_conv;
5844 }
5845
5846 static jclass LDKCOption_u16Z_Some_class = NULL;
5847 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
5848 static jclass LDKCOption_u16Z_None_class = NULL;
5849 static jmethodID LDKCOption_u16Z_None_meth = NULL;
5850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
5851         LDKCOption_u16Z_Some_class =
5852                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
5853         CHECK(LDKCOption_u16Z_Some_class != NULL);
5854         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
5855         CHECK(LDKCOption_u16Z_Some_meth != NULL);
5856         LDKCOption_u16Z_None_class =
5857                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
5858         CHECK(LDKCOption_u16Z_None_class != NULL);
5859         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
5860         CHECK(LDKCOption_u16Z_None_meth != NULL);
5861 }
5862 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5863         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
5864         switch(obj->tag) {
5865                 case LDKCOption_u16Z_Some: {
5866                         int16_t some_conv = obj->some;
5867                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, some_conv);
5868                 }
5869                 case LDKCOption_u16Z_None: {
5870                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
5871                 }
5872                 default: abort();
5873         }
5874 }
5875 static jclass LDKAPIError_APIMisuseError_class = NULL;
5876 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
5877 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
5878 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
5879 static jclass LDKAPIError_RouteError_class = NULL;
5880 static jmethodID LDKAPIError_RouteError_meth = NULL;
5881 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
5882 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
5883 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
5884 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
5885 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
5886 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
5887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
5888         LDKAPIError_APIMisuseError_class =
5889                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
5890         CHECK(LDKAPIError_APIMisuseError_class != NULL);
5891         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
5892         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
5893         LDKAPIError_FeeRateTooHigh_class =
5894                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
5895         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
5896         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
5897         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
5898         LDKAPIError_RouteError_class =
5899                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$RouteError"));
5900         CHECK(LDKAPIError_RouteError_class != NULL);
5901         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
5902         CHECK(LDKAPIError_RouteError_meth != NULL);
5903         LDKAPIError_ChannelUnavailable_class =
5904                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
5905         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
5906         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
5907         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
5908         LDKAPIError_MonitorUpdateFailed_class =
5909                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed"));
5910         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
5911         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
5912         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
5913         LDKAPIError_IncompatibleShutdownScript_class =
5914                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
5915         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
5916         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
5917         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
5918 }
5919 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5920         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5921         switch(obj->tag) {
5922                 case LDKAPIError_APIMisuseError: {
5923                         LDKStr err_str = obj->api_misuse_error.err;
5924                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5925                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
5926                 }
5927                 case LDKAPIError_FeeRateTooHigh: {
5928                         LDKStr err_str = obj->fee_rate_too_high.err;
5929                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5930                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
5931                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, feerate_conv);
5932                 }
5933                 case LDKAPIError_RouteError: {
5934                         LDKStr err_str = obj->route_error.err;
5935                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5936                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
5937                 }
5938                 case LDKAPIError_ChannelUnavailable: {
5939                         LDKStr err_str = obj->channel_unavailable.err;
5940                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5941                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
5942                 }
5943                 case LDKAPIError_MonitorUpdateFailed: {
5944                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
5945                 }
5946                 case LDKAPIError_IncompatibleShutdownScript: {
5947                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
5948                         int64_t script_ref = 0;
5949                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5950                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5951                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
5952                         script_ref = (uintptr_t)script_var.inner & ~1;
5953                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
5954                 }
5955                 default: abort();
5956         }
5957 }
5958 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5959 CHECK(owner->result_ok);
5960         return *owner->contents.result;
5961 }
5962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5963         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
5964         CResult_NoneAPIErrorZ_get_ok(owner_conv);
5965 }
5966
5967 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5968 CHECK(!owner->result_ok);
5969         return APIError_clone(&*owner->contents.err);
5970 }
5971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5972         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
5973         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5974         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
5975         int64_t ret_ref = (uintptr_t)ret_copy;
5976         return ret_ref;
5977 }
5978
5979 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
5980         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
5981         for (size_t i = 0; i < ret.datalen; i++) {
5982                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
5983         }
5984         return ret;
5985 }
5986 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
5987         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
5988         for (size_t i = 0; i < ret.datalen; i++) {
5989                 ret.data[i] = APIError_clone(&orig->data[i]);
5990         }
5991         return ret;
5992 }
5993 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
5994 CHECK(owner->result_ok);
5995         return ThirtyTwoBytes_clone(&*owner->contents.result);
5996 }
5997 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5998         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
5999         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6000         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
6001         return ret_arr;
6002 }
6003
6004 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6005 CHECK(!owner->result_ok);
6006         return APIError_clone(&*owner->contents.err);
6007 }
6008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6009         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
6010         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6011         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
6012         int64_t ret_ref = (uintptr_t)ret_copy;
6013         return ret_ref;
6014 }
6015
6016 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
6017 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
6018 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
6019 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
6020 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
6021 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
6022 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
6023 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
6024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
6025         LDKPaymentSendFailure_ParameterError_class =
6026                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
6027         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
6028         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
6029         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
6030         LDKPaymentSendFailure_PathParameterError_class =
6031                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
6032         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
6033         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
6034         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
6035         LDKPaymentSendFailure_AllFailedRetrySafe_class =
6036                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe"));
6037         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
6038         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
6039         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
6040         LDKPaymentSendFailure_PartialFailure_class =
6041                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
6042         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
6043         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
6044         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
6045 }
6046 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6047         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
6048         switch(obj->tag) {
6049                 case LDKPaymentSendFailure_ParameterError: {
6050                         int64_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
6051                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
6052                 }
6053                 case LDKPaymentSendFailure_PathParameterError: {
6054                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
6055                         int64_tArray path_parameter_error_arr = NULL;
6056                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
6057                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
6058                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
6059                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6060                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
6061                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
6062                                 path_parameter_error_arr_ptr[w] = (int64_t)path_parameter_error_conv_22_conv;
6063                         }
6064                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
6065                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
6066                 }
6067                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
6068                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
6069                         int64_tArray all_failed_retry_safe_arr = NULL;
6070                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
6071                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
6072                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
6073                                 int64_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
6074                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
6075                         }
6076                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
6077                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
6078                 }
6079                 case LDKPaymentSendFailure_PartialFailure: {
6080                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
6081                         int64_tArray results_arr = NULL;
6082                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
6083                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
6084                         for (size_t w = 0; w < results_var.datalen; w++) {
6085                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6086                                 *results_conv_22_conv = results_var.data[w];
6087                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
6088                                 results_arr_ptr[w] = (int64_t)results_conv_22_conv;
6089                         }
6090                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
6091                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
6092                         int64_t failed_paths_retry_ref = 0;
6093                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
6094                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6095                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6096                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
6097                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
6098                         }
6099                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
6100                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
6101                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
6102                 }
6103                 default: abort();
6104         }
6105 }
6106 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
6107 CHECK(owner->result_ok);
6108         return ThirtyTwoBytes_clone(&*owner->contents.result);
6109 }
6110 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6111         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
6112         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6113         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data);
6114         return ret_arr;
6115 }
6116
6117 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
6118 CHECK(!owner->result_ok);
6119         return PaymentSendFailure_clone(&*owner->contents.err);
6120 }
6121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6122         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
6123         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6124         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
6125         int64_t ret_ref = (uintptr_t)ret_copy;
6126         return ret_ref;
6127 }
6128
6129 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6130 CHECK(owner->result_ok);
6131         return *owner->contents.result;
6132 }
6133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6134         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
6135         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
6136 }
6137
6138 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6139 CHECK(!owner->result_ok);
6140         return PaymentSendFailure_clone(&*owner->contents.err);
6141 }
6142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6143         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
6144         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6145         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
6146         int64_t ret_ref = (uintptr_t)ret_copy;
6147         return ret_ref;
6148 }
6149
6150 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6151         return ThirtyTwoBytes_clone(&owner->a);
6152 }
6153 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6154         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
6155         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6156         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
6157         return ret_arr;
6158 }
6159
6160 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6161         return ThirtyTwoBytes_clone(&owner->b);
6162 }
6163 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6164         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
6165         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6166         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
6167         return ret_arr;
6168 }
6169
6170 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6171 CHECK(owner->result_ok);
6172         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
6173 }
6174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6175         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
6176         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
6177         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
6178         return ((int64_t)ret_conv);
6179 }
6180
6181 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6182 CHECK(!owner->result_ok);
6183         return PaymentSendFailure_clone(&*owner->contents.err);
6184 }
6185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6186         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
6187         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6188         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
6189         int64_t ret_ref = (uintptr_t)ret_copy;
6190         return ret_ref;
6191 }
6192
6193 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
6194         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
6195         for (size_t i = 0; i < ret.datalen; i++) {
6196                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
6197         }
6198         return ret;
6199 }
6200 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6201         return ThirtyTwoBytes_clone(&owner->a);
6202 }
6203 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6204         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
6205         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6206         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
6207         return ret_arr;
6208 }
6209
6210 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6211         return ThirtyTwoBytes_clone(&owner->b);
6212 }
6213 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6214         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
6215         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6216         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
6217         return ret_arr;
6218 }
6219
6220 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6221 CHECK(owner->result_ok);
6222         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6223 }
6224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6225         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
6226         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6227         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
6228         return ((int64_t)ret_conv);
6229 }
6230
6231 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6232 CHECK(!owner->result_ok);
6233         return *owner->contents.err;
6234 }
6235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6236         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
6237         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
6238 }
6239
6240 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6241 CHECK(owner->result_ok);
6242         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6243 }
6244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6245         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
6246         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6247         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
6248         return ((int64_t)ret_conv);
6249 }
6250
6251 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6252 CHECK(!owner->result_ok);
6253         return APIError_clone(&*owner->contents.err);
6254 }
6255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6256         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
6257         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6258         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
6259         int64_t ret_ref = (uintptr_t)ret_copy;
6260         return ret_ref;
6261 }
6262
6263 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6264 CHECK(owner->result_ok);
6265         return ThirtyTwoBytes_clone(&*owner->contents.result);
6266 }
6267 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6268         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
6269         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6270         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
6271         return ret_arr;
6272 }
6273
6274 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6275 CHECK(!owner->result_ok);
6276         return *owner->contents.err;
6277 }
6278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6279         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
6280         CResult_PaymentSecretNoneZ_get_err(owner_conv);
6281 }
6282
6283 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6284 CHECK(owner->result_ok);
6285         return ThirtyTwoBytes_clone(&*owner->contents.result);
6286 }
6287 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6288         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
6289         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6290         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
6291         return ret_arr;
6292 }
6293
6294 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6295 CHECK(!owner->result_ok);
6296         return APIError_clone(&*owner->contents.err);
6297 }
6298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6299         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
6300         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6301         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
6302         int64_t ret_ref = (uintptr_t)ret_copy;
6303         return ret_ref;
6304 }
6305
6306 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6307 CHECK(owner->result_ok);
6308         return ThirtyTwoBytes_clone(&*owner->contents.result);
6309 }
6310 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6311         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
6312         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6313         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
6314         return ret_arr;
6315 }
6316
6317 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6318 CHECK(!owner->result_ok);
6319         return APIError_clone(&*owner->contents.err);
6320 }
6321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6322         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
6323         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6324         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
6325         int64_t ret_ref = (uintptr_t)ret_copy;
6326         return ret_ref;
6327 }
6328
6329 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6330 CHECK(owner->result_ok);
6331         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
6332 }
6333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6334         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
6335         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
6336         int64_t ret_ref = 0;
6337         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6338         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6339         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6340         ret_ref = (uintptr_t)ret_var.inner;
6341         if (ret_var.is_owned) {
6342                 ret_ref |= 1;
6343         }
6344         return ret_ref;
6345 }
6346
6347 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6348 CHECK(!owner->result_ok);
6349         return DecodeError_clone(&*owner->contents.err);
6350 }
6351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6352         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
6353         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
6354         int64_t ret_ref = 0;
6355         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6356         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6358         ret_ref = (uintptr_t)ret_var.inner;
6359         if (ret_var.is_owned) {
6360                 ret_ref |= 1;
6361         }
6362         return ret_ref;
6363 }
6364
6365 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6366 CHECK(owner->result_ok);
6367         return ChannelCounterparty_clone(&*owner->contents.result);
6368 }
6369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6370         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
6371         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
6372         int64_t ret_ref = 0;
6373         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6374         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6375         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6376         ret_ref = (uintptr_t)ret_var.inner;
6377         if (ret_var.is_owned) {
6378                 ret_ref |= 1;
6379         }
6380         return ret_ref;
6381 }
6382
6383 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6384 CHECK(!owner->result_ok);
6385         return DecodeError_clone(&*owner->contents.err);
6386 }
6387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6388         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
6389         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
6390         int64_t ret_ref = 0;
6391         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6392         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6394         ret_ref = (uintptr_t)ret_var.inner;
6395         if (ret_var.is_owned) {
6396                 ret_ref |= 1;
6397         }
6398         return ret_ref;
6399 }
6400
6401 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6402 CHECK(owner->result_ok);
6403         return ChannelDetails_clone(&*owner->contents.result);
6404 }
6405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6406         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
6407         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
6408         int64_t ret_ref = 0;
6409         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6410         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6412         ret_ref = (uintptr_t)ret_var.inner;
6413         if (ret_var.is_owned) {
6414                 ret_ref |= 1;
6415         }
6416         return ret_ref;
6417 }
6418
6419 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6420 CHECK(!owner->result_ok);
6421         return DecodeError_clone(&*owner->contents.err);
6422 }
6423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6424         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
6425         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
6426         int64_t ret_ref = 0;
6427         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6428         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6430         ret_ref = (uintptr_t)ret_var.inner;
6431         if (ret_var.is_owned) {
6432                 ret_ref |= 1;
6433         }
6434         return ret_ref;
6435 }
6436
6437 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6438 CHECK(owner->result_ok);
6439         return PhantomRouteHints_clone(&*owner->contents.result);
6440 }
6441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6442         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
6443         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
6444         int64_t ret_ref = 0;
6445         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6446         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6448         ret_ref = (uintptr_t)ret_var.inner;
6449         if (ret_var.is_owned) {
6450                 ret_ref |= 1;
6451         }
6452         return ret_ref;
6453 }
6454
6455 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6456 CHECK(!owner->result_ok);
6457         return DecodeError_clone(&*owner->contents.err);
6458 }
6459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6460         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
6461         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
6462         int64_t ret_ref = 0;
6463         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6464         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6466         ret_ref = (uintptr_t)ret_var.inner;
6467         if (ret_var.is_owned) {
6468                 ret_ref |= 1;
6469         }
6470         return ret_ref;
6471 }
6472
6473 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
6474         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
6475         for (size_t i = 0; i < ret.datalen; i++) {
6476                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
6477         }
6478         return ret;
6479 }
6480 typedef struct LDKWatch_JCalls {
6481         atomic_size_t refcnt;
6482         JavaVM *vm;
6483         jweak o;
6484         jmethodID watch_channel_meth;
6485         jmethodID update_channel_meth;
6486         jmethodID release_pending_monitor_events_meth;
6487 } LDKWatch_JCalls;
6488 static void LDKWatch_JCalls_free(void* this_arg) {
6489         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6490         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6491                 JNIEnv *env;
6492                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6493                 if (get_jenv_res == JNI_EDETACHED) {
6494                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6495                 } else {
6496                         DO_ASSERT(get_jenv_res == JNI_OK);
6497                 }
6498                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6499                 if (get_jenv_res == JNI_EDETACHED) {
6500                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6501                 }
6502                 FREE(j_calls);
6503         }
6504 }
6505 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
6506         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6507         JNIEnv *env;
6508         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6509         if (get_jenv_res == JNI_EDETACHED) {
6510                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6511         } else {
6512                 DO_ASSERT(get_jenv_res == JNI_OK);
6513         }
6514         LDKOutPoint funding_txo_var = funding_txo;
6515         int64_t funding_txo_ref = 0;
6516         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6517         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6518         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6519         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
6520         if (funding_txo_var.is_owned) {
6521                 funding_txo_ref |= 1;
6522         }
6523         LDKChannelMonitor monitor_var = monitor;
6524         int64_t monitor_ref = 0;
6525         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6526         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6527         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
6528         monitor_ref = (uintptr_t)monitor_var.inner;
6529         if (monitor_var.is_owned) {
6530                 monitor_ref |= 1;
6531         }
6532         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6533         CHECK(obj != NULL);
6534         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
6535         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6536                 (*env)->ExceptionDescribe(env);
6537                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
6538         }
6539         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6540         CHECK_ACCESS(ret_ptr);
6541         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6542         FREE((void*)ret);
6543         if (get_jenv_res == JNI_EDETACHED) {
6544                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6545         }
6546         return ret_conv;
6547 }
6548 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
6549         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6550         JNIEnv *env;
6551         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6552         if (get_jenv_res == JNI_EDETACHED) {
6553                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6554         } else {
6555                 DO_ASSERT(get_jenv_res == JNI_OK);
6556         }
6557         LDKOutPoint funding_txo_var = funding_txo;
6558         int64_t funding_txo_ref = 0;
6559         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6560         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6561         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6562         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
6563         if (funding_txo_var.is_owned) {
6564                 funding_txo_ref |= 1;
6565         }
6566         LDKChannelMonitorUpdate update_var = update;
6567         int64_t update_ref = 0;
6568         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6569         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6570         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
6571         update_ref = (uintptr_t)update_var.inner;
6572         if (update_var.is_owned) {
6573                 update_ref |= 1;
6574         }
6575         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6576         CHECK(obj != NULL);
6577         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
6578         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6579                 (*env)->ExceptionDescribe(env);
6580                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
6581         }
6582         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6583         CHECK_ACCESS(ret_ptr);
6584         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6585         FREE((void*)ret);
6586         if (get_jenv_res == JNI_EDETACHED) {
6587                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6588         }
6589         return ret_conv;
6590 }
6591 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
6592         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6593         JNIEnv *env;
6594         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6595         if (get_jenv_res == JNI_EDETACHED) {
6596                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6597         } else {
6598                 DO_ASSERT(get_jenv_res == JNI_OK);
6599         }
6600         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6601         CHECK(obj != NULL);
6602         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
6603         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6604                 (*env)->ExceptionDescribe(env);
6605                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
6606         }
6607         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_constr;
6608         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6609         if (ret_constr.datalen > 0)
6610                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
6611         else
6612                 ret_constr.data = NULL;
6613         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6614         for (size_t x = 0; x < ret_constr.datalen; x++) {
6615                 int64_t ret_conv_49 = ret_vals[x];
6616                 void* ret_conv_49_ptr = (void*)(((uintptr_t)ret_conv_49) & ~1);
6617                 CHECK_ACCESS(ret_conv_49_ptr);
6618                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ ret_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(ret_conv_49_ptr);
6619                 FREE((void*)ret_conv_49);
6620                 ret_constr.data[x] = ret_conv_49_conv;
6621         }
6622         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6623         if (get_jenv_res == JNI_EDETACHED) {
6624                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6625         }
6626         return ret_constr;
6627 }
6628 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
6629         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
6630         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6631 }
6632 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
6633         jclass c = (*env)->GetObjectClass(env, o);
6634         CHECK(c != NULL);
6635         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
6636         atomic_init(&calls->refcnt, 1);
6637         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6638         calls->o = (*env)->NewWeakGlobalRef(env, o);
6639         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
6640         CHECK(calls->watch_channel_meth != NULL);
6641         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
6642         CHECK(calls->update_channel_meth != NULL);
6643         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
6644         CHECK(calls->release_pending_monitor_events_meth != NULL);
6645
6646         LDKWatch ret = {
6647                 .this_arg = (void*) calls,
6648                 .watch_channel = watch_channel_LDKWatch_jcall,
6649                 .update_channel = update_channel_LDKWatch_jcall,
6650                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
6651                 .free = LDKWatch_JCalls_free,
6652         };
6653         return ret;
6654 }
6655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
6656         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
6657         *res_ptr = LDKWatch_init(env, clz, o);
6658         return (uint64_t)res_ptr;
6659 }
6660 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) {
6661         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6662         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6663         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6664         LDKOutPoint funding_txo_conv;
6665         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6666         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6667         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6668         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6669         LDKChannelMonitor monitor_conv;
6670         monitor_conv.inner = (void*)(monitor & (~1));
6671         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
6672         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
6673         monitor_conv = ChannelMonitor_clone(&monitor_conv);
6674         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6675         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
6676         return (int64_t)ret_conv;
6677 }
6678
6679 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) {
6680         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6681         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6682         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6683         LDKOutPoint funding_txo_conv;
6684         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6685         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6686         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6687         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6688         LDKChannelMonitorUpdate update_conv;
6689         update_conv.inner = (void*)(update & (~1));
6690         update_conv.is_owned = (update & 1) || (update == 0);
6691         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
6692         update_conv = ChannelMonitorUpdate_clone(&update_conv);
6693         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6694         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
6695         return (int64_t)ret_conv;
6696 }
6697
6698 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6699         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6700         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6701         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6702         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
6703         int64_tArray ret_arr = NULL;
6704         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6705         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6706         for (size_t x = 0; x < ret_var.datalen; x++) {
6707                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
6708                 *ret_conv_49_conv = ret_var.data[x];
6709                 ret_arr_ptr[x] = ((int64_t)ret_conv_49_conv);
6710         }
6711         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6712         FREE(ret_var.data);
6713         return ret_arr;
6714 }
6715
6716 typedef struct LDKBroadcasterInterface_JCalls {
6717         atomic_size_t refcnt;
6718         JavaVM *vm;
6719         jweak o;
6720         jmethodID broadcast_transaction_meth;
6721 } LDKBroadcasterInterface_JCalls;
6722 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
6723         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6724         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6725                 JNIEnv *env;
6726                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6727                 if (get_jenv_res == JNI_EDETACHED) {
6728                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6729                 } else {
6730                         DO_ASSERT(get_jenv_res == JNI_OK);
6731                 }
6732                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6733                 if (get_jenv_res == JNI_EDETACHED) {
6734                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6735                 }
6736                 FREE(j_calls);
6737         }
6738 }
6739 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
6740         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6741         JNIEnv *env;
6742         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6743         if (get_jenv_res == JNI_EDETACHED) {
6744                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6745         } else {
6746                 DO_ASSERT(get_jenv_res == JNI_OK);
6747         }
6748         LDKTransaction tx_var = tx;
6749         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
6750         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
6751         Transaction_free(tx_var);
6752         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6753         CHECK(obj != NULL);
6754         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
6755         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6756                 (*env)->ExceptionDescribe(env);
6757                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
6758         }
6759         if (get_jenv_res == JNI_EDETACHED) {
6760                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6761         }
6762 }
6763 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
6764         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
6765         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6766 }
6767 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
6768         jclass c = (*env)->GetObjectClass(env, o);
6769         CHECK(c != NULL);
6770         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
6771         atomic_init(&calls->refcnt, 1);
6772         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6773         calls->o = (*env)->NewWeakGlobalRef(env, o);
6774         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
6775         CHECK(calls->broadcast_transaction_meth != NULL);
6776
6777         LDKBroadcasterInterface ret = {
6778                 .this_arg = (void*) calls,
6779                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
6780                 .free = LDKBroadcasterInterface_JCalls_free,
6781         };
6782         return ret;
6783 }
6784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
6785         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
6786         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
6787         return (uint64_t)res_ptr;
6788 }
6789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
6790         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6791         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6792         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
6793         LDKTransaction tx_ref;
6794         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
6795         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
6796         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
6797         tx_ref.data_is_owned = true;
6798         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
6799 }
6800
6801 typedef struct LDKKeysInterface_JCalls {
6802         atomic_size_t refcnt;
6803         JavaVM *vm;
6804         jweak o;
6805         jmethodID get_node_secret_meth;
6806         jmethodID get_destination_script_meth;
6807         jmethodID get_shutdown_scriptpubkey_meth;
6808         jmethodID get_channel_signer_meth;
6809         jmethodID get_secure_random_bytes_meth;
6810         jmethodID read_chan_signer_meth;
6811         jmethodID sign_invoice_meth;
6812         jmethodID get_inbound_payment_key_material_meth;
6813 } LDKKeysInterface_JCalls;
6814 static void LDKKeysInterface_JCalls_free(void* this_arg) {
6815         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6816         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6817                 JNIEnv *env;
6818                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6819                 if (get_jenv_res == JNI_EDETACHED) {
6820                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6821                 } else {
6822                         DO_ASSERT(get_jenv_res == JNI_OK);
6823                 }
6824                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6825                 if (get_jenv_res == JNI_EDETACHED) {
6826                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6827                 }
6828                 FREE(j_calls);
6829         }
6830 }
6831 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
6832         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6833         JNIEnv *env;
6834         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6835         if (get_jenv_res == JNI_EDETACHED) {
6836                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6837         } else {
6838                 DO_ASSERT(get_jenv_res == JNI_OK);
6839         }
6840         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
6841         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6842         CHECK(obj != NULL);
6843         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth, recipient_conv);
6844         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6845                 (*env)->ExceptionDescribe(env);
6846                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
6847         }
6848         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6849         CHECK_ACCESS(ret_ptr);
6850         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
6851         FREE((void*)ret);
6852         if (get_jenv_res == JNI_EDETACHED) {
6853                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6854         }
6855         return ret_conv;
6856 }
6857 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
6858         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6859         JNIEnv *env;
6860         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6861         if (get_jenv_res == JNI_EDETACHED) {
6862                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6863         } else {
6864                 DO_ASSERT(get_jenv_res == JNI_OK);
6865         }
6866         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6867         CHECK(obj != NULL);
6868         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
6869         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6870                 (*env)->ExceptionDescribe(env);
6871                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
6872         }
6873         LDKCVec_u8Z ret_ref;
6874         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
6875         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6876         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
6877         if (get_jenv_res == JNI_EDETACHED) {
6878                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6879         }
6880         return ret_ref;
6881 }
6882 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
6883         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6884         JNIEnv *env;
6885         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6886         if (get_jenv_res == JNI_EDETACHED) {
6887                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6888         } else {
6889                 DO_ASSERT(get_jenv_res == JNI_OK);
6890         }
6891         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6892         CHECK(obj != NULL);
6893         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
6894         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6895                 (*env)->ExceptionDescribe(env);
6896                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
6897         }
6898         LDKShutdownScript ret_conv;
6899         ret_conv.inner = (void*)(ret & (~1));
6900         ret_conv.is_owned = (ret & 1) || (ret == 0);
6901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
6902         if (get_jenv_res == JNI_EDETACHED) {
6903                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6904         }
6905         return ret_conv;
6906 }
6907 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
6908         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
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         jboolean inbound_conv = inbound;
6917         int64_t channel_value_satoshis_conv = channel_value_satoshis;
6918         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6919         CHECK(obj != NULL);
6920         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound_conv, channel_value_satoshis_conv);
6921         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6922                 (*env)->ExceptionDescribe(env);
6923                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
6924         }
6925         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6926         CHECK_ACCESS(ret_ptr);
6927         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
6928         FREE((void*)ret);
6929         if (get_jenv_res == JNI_EDETACHED) {
6930                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6931         }
6932         return ret_conv;
6933 }
6934 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
6935         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6936         JNIEnv *env;
6937         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6938         if (get_jenv_res == JNI_EDETACHED) {
6939                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6940         } else {
6941                 DO_ASSERT(get_jenv_res == JNI_OK);
6942         }
6943         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6944         CHECK(obj != NULL);
6945         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
6946         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6947                 (*env)->ExceptionDescribe(env);
6948                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
6949         }
6950         LDKThirtyTwoBytes ret_ref;
6951         CHECK((*env)->GetArrayLength(env, ret) == 32);
6952         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
6953         if (get_jenv_res == JNI_EDETACHED) {
6954                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6955         }
6956         return ret_ref;
6957 }
6958 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
6959         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6960         JNIEnv *env;
6961         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6962         if (get_jenv_res == JNI_EDETACHED) {
6963                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6964         } else {
6965                 DO_ASSERT(get_jenv_res == JNI_OK);
6966         }
6967         LDKu8slice reader_var = reader;
6968         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
6969         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
6970         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6971         CHECK(obj != NULL);
6972         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
6973         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6974                 (*env)->ExceptionDescribe(env);
6975                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
6976         }
6977         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6978         CHECK_ACCESS(ret_ptr);
6979         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
6980         FREE((void*)ret);
6981         if (get_jenv_res == JNI_EDETACHED) {
6982                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6983         }
6984         return ret_conv;
6985 }
6986 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
6987         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6988         JNIEnv *env;
6989         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6990         if (get_jenv_res == JNI_EDETACHED) {
6991                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6992         } else {
6993                 DO_ASSERT(get_jenv_res == JNI_OK);
6994         }
6995         LDKu8slice hrp_bytes_var = hrp_bytes;
6996         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
6997         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
6998         LDKCVec_u5Z invoice_data_var = invoice_data;
6999         jobjectArray invoice_data_arr = NULL;
7000         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
7001         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
7002         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
7003                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
7004                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
7005         }
7006         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
7007         FREE(invoice_data_var.data);
7008         jclass receipient_conv = LDKRecipient_to_java(env, receipient);
7009         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7010         CHECK(obj != NULL);
7011         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, receipient_conv);
7012         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7013                 (*env)->ExceptionDescribe(env);
7014                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
7015         }
7016         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
7017         CHECK_ACCESS(ret_ptr);
7018         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
7019         FREE((void*)ret);
7020         if (get_jenv_res == JNI_EDETACHED) {
7021                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7022         }
7023         return ret_conv;
7024 }
7025 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
7026         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7027         JNIEnv *env;
7028         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7029         if (get_jenv_res == JNI_EDETACHED) {
7030                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7031         } else {
7032                 DO_ASSERT(get_jenv_res == JNI_OK);
7033         }
7034         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7035         CHECK(obj != NULL);
7036         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
7037         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7038                 (*env)->ExceptionDescribe(env);
7039                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
7040         }
7041         LDKThirtyTwoBytes ret_ref;
7042         CHECK((*env)->GetArrayLength(env, ret) == 32);
7043         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7044         if (get_jenv_res == JNI_EDETACHED) {
7045                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7046         }
7047         return ret_ref;
7048 }
7049 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
7050         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
7051         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7052 }
7053 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
7054         jclass c = (*env)->GetObjectClass(env, o);
7055         CHECK(c != NULL);
7056         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
7057         atomic_init(&calls->refcnt, 1);
7058         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7059         calls->o = (*env)->NewWeakGlobalRef(env, o);
7060         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "(Lorg/ldk/enums/Recipient;)J");
7061         CHECK(calls->get_node_secret_meth != NULL);
7062         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
7063         CHECK(calls->get_destination_script_meth != NULL);
7064         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
7065         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
7066         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
7067         CHECK(calls->get_channel_signer_meth != NULL);
7068         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
7069         CHECK(calls->get_secure_random_bytes_meth != NULL);
7070         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
7071         CHECK(calls->read_chan_signer_meth != NULL);
7072         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
7073         CHECK(calls->sign_invoice_meth != NULL);
7074         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
7075         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
7076
7077         LDKKeysInterface ret = {
7078                 .this_arg = (void*) calls,
7079                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
7080                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
7081                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
7082                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
7083                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
7084                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
7085                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
7086                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
7087                 .free = LDKKeysInterface_JCalls_free,
7088         };
7089         return ret;
7090 }
7091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
7092         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
7093         *res_ptr = LDKKeysInterface_init(env, clz, o);
7094         return (uint64_t)res_ptr;
7095 }
7096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
7097         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7098         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7099         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7100         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7101         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
7102         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
7103         return (int64_t)ret_conv;
7104 }
7105
7106 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
7107         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7108         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7109         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7110         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
7111         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7112         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7113         CVec_u8Z_free(ret_var);
7114         return ret_arr;
7115 }
7116
7117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
7118         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7119         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7120         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7121         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
7122         int64_t ret_ref = 0;
7123         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7124         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7126         ret_ref = (uintptr_t)ret_var.inner;
7127         if (ret_var.is_owned) {
7128                 ret_ref |= 1;
7129         }
7130         return ret_ref;
7131 }
7132
7133 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) {
7134         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7135         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7136         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7137         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
7138         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
7139         return (int64_t)ret_ret;
7140 }
7141
7142 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
7143         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7144         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7145         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7146         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7147         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
7148         return ret_arr;
7149 }
7150
7151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
7152         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7153         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7154         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7155         LDKu8slice reader_ref;
7156         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
7157         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
7158         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7159         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
7160         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
7161         return (int64_t)ret_conv;
7162 }
7163
7164 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) {
7165         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7166         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7167         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7168         LDKu8slice hrp_bytes_ref;
7169         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
7170         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
7171         LDKCVec_u5Z invoice_data_constr;
7172         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
7173         if (invoice_data_constr.datalen > 0)
7174                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
7175         else
7176                 invoice_data_constr.data = NULL;
7177         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
7178         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
7179                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
7180                 
7181                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
7182         }
7183         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
7184         LDKRecipient receipient_conv = LDKRecipient_from_java(env, receipient);
7185         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7186         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
7187         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
7188         return (int64_t)ret_conv;
7189 }
7190
7191 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
7192         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7193         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7194         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7195         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7196         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
7197         return ret_arr;
7198 }
7199
7200 typedef struct LDKFeeEstimator_JCalls {
7201         atomic_size_t refcnt;
7202         JavaVM *vm;
7203         jweak o;
7204         jmethodID get_est_sat_per_1000_weight_meth;
7205 } LDKFeeEstimator_JCalls;
7206 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
7207         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7208         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7209                 JNIEnv *env;
7210                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7211                 if (get_jenv_res == JNI_EDETACHED) {
7212                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7213                 } else {
7214                         DO_ASSERT(get_jenv_res == JNI_OK);
7215                 }
7216                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7217                 if (get_jenv_res == JNI_EDETACHED) {
7218                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7219                 }
7220                 FREE(j_calls);
7221         }
7222 }
7223 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
7224         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7225         JNIEnv *env;
7226         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7227         if (get_jenv_res == JNI_EDETACHED) {
7228                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7229         } else {
7230                 DO_ASSERT(get_jenv_res == JNI_OK);
7231         }
7232         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
7233         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7234         CHECK(obj != NULL);
7235         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
7236         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7237                 (*env)->ExceptionDescribe(env);
7238                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
7239         }
7240         if (get_jenv_res == JNI_EDETACHED) {
7241                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7242         }
7243         return ret;
7244 }
7245 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
7246         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
7247         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7248 }
7249 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
7250         jclass c = (*env)->GetObjectClass(env, o);
7251         CHECK(c != NULL);
7252         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
7253         atomic_init(&calls->refcnt, 1);
7254         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7255         calls->o = (*env)->NewWeakGlobalRef(env, o);
7256         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
7257         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
7258
7259         LDKFeeEstimator ret = {
7260                 .this_arg = (void*) calls,
7261                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
7262                 .free = LDKFeeEstimator_JCalls_free,
7263         };
7264         return ret;
7265 }
7266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
7267         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
7268         *res_ptr = LDKFeeEstimator_init(env, clz, o);
7269         return (uint64_t)res_ptr;
7270 }
7271 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) {
7272         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7273         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7274         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
7275         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
7276         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
7277         return ret_conv;
7278 }
7279
7280 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7281         return ThirtyTwoBytes_clone(&owner->a);
7282 }
7283 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7284         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
7285         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7286         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
7287         return ret_arr;
7288 }
7289
7290 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7291         return &owner->b;
7292 }
7293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7294         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
7295         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
7296         int64_t ret_ref = 0;
7297         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7298         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7299         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7300         ret_ref = (uintptr_t)ret_var.inner & ~1;
7301         return ret_ref;
7302 }
7303
7304 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7305 CHECK(owner->result_ok);
7306         return &*owner->contents.result;
7307 }
7308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7309         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
7310         int64_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
7311         return ret_ret;
7312 }
7313
7314 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7315 CHECK(!owner->result_ok);
7316         return DecodeError_clone(&*owner->contents.err);
7317 }
7318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7319         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
7320         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
7321         int64_t ret_ref = 0;
7322         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7323         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7324         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7325         ret_ref = (uintptr_t)ret_var.inner;
7326         if (ret_var.is_owned) {
7327                 ret_ref |= 1;
7328         }
7329         return ret_ref;
7330 }
7331
7332 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7333 CHECK(owner->result_ok);
7334         return ChannelConfig_clone(&*owner->contents.result);
7335 }
7336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7337         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
7338         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
7339         int64_t ret_ref = 0;
7340         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7341         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7343         ret_ref = (uintptr_t)ret_var.inner;
7344         if (ret_var.is_owned) {
7345                 ret_ref |= 1;
7346         }
7347         return ret_ref;
7348 }
7349
7350 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7351 CHECK(!owner->result_ok);
7352         return DecodeError_clone(&*owner->contents.err);
7353 }
7354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7355         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
7356         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
7357         int64_t ret_ref = 0;
7358         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7359         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7361         ret_ref = (uintptr_t)ret_var.inner;
7362         if (ret_var.is_owned) {
7363                 ret_ref |= 1;
7364         }
7365         return ret_ref;
7366 }
7367
7368 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7369 CHECK(owner->result_ok);
7370         return OutPoint_clone(&*owner->contents.result);
7371 }
7372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7373         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
7374         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
7375         int64_t ret_ref = 0;
7376         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7377         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7379         ret_ref = (uintptr_t)ret_var.inner;
7380         if (ret_var.is_owned) {
7381                 ret_ref |= 1;
7382         }
7383         return ret_ref;
7384 }
7385
7386 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7387 CHECK(!owner->result_ok);
7388         return DecodeError_clone(&*owner->contents.err);
7389 }
7390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7391         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
7392         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
7393         int64_t ret_ref = 0;
7394         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7395         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7396         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7397         ret_ref = (uintptr_t)ret_var.inner;
7398         if (ret_var.is_owned) {
7399                 ret_ref |= 1;
7400         }
7401         return ret_ref;
7402 }
7403
7404 typedef struct LDKType_JCalls {
7405         atomic_size_t refcnt;
7406         JavaVM *vm;
7407         jweak o;
7408         jmethodID type_id_meth;
7409         jmethodID debug_str_meth;
7410         jmethodID write_meth;
7411 } LDKType_JCalls;
7412 static void LDKType_JCalls_free(void* this_arg) {
7413         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7414         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7415                 JNIEnv *env;
7416                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7417                 if (get_jenv_res == JNI_EDETACHED) {
7418                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7419                 } else {
7420                         DO_ASSERT(get_jenv_res == JNI_OK);
7421                 }
7422                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7423                 if (get_jenv_res == JNI_EDETACHED) {
7424                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7425                 }
7426                 FREE(j_calls);
7427         }
7428 }
7429 uint16_t type_id_LDKType_jcall(const void* this_arg) {
7430         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7431         JNIEnv *env;
7432         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7433         if (get_jenv_res == JNI_EDETACHED) {
7434                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7435         } else {
7436                 DO_ASSERT(get_jenv_res == JNI_OK);
7437         }
7438         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7439         CHECK(obj != NULL);
7440         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
7441         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7442                 (*env)->ExceptionDescribe(env);
7443                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
7444         }
7445         if (get_jenv_res == JNI_EDETACHED) {
7446                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7447         }
7448         return ret;
7449 }
7450 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
7451         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7452         JNIEnv *env;
7453         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7454         if (get_jenv_res == JNI_EDETACHED) {
7455                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7456         } else {
7457                 DO_ASSERT(get_jenv_res == JNI_OK);
7458         }
7459         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7460         CHECK(obj != NULL);
7461         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
7462         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7463                 (*env)->ExceptionDescribe(env);
7464                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
7465         }
7466         LDKStr ret_conv = java_to_owned_str(env, ret);
7467         if (get_jenv_res == JNI_EDETACHED) {
7468                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7469         }
7470         return ret_conv;
7471 }
7472 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
7473         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7474         JNIEnv *env;
7475         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7476         if (get_jenv_res == JNI_EDETACHED) {
7477                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7478         } else {
7479                 DO_ASSERT(get_jenv_res == JNI_OK);
7480         }
7481         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7482         CHECK(obj != NULL);
7483         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
7484         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7485                 (*env)->ExceptionDescribe(env);
7486                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
7487         }
7488         LDKCVec_u8Z ret_ref;
7489         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
7490         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7491         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
7492         if (get_jenv_res == JNI_EDETACHED) {
7493                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7494         }
7495         return ret_ref;
7496 }
7497 static void LDKType_JCalls_cloned(LDKType* new_obj) {
7498         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
7499         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7500 }
7501 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
7502         jclass c = (*env)->GetObjectClass(env, o);
7503         CHECK(c != NULL);
7504         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
7505         atomic_init(&calls->refcnt, 1);
7506         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7507         calls->o = (*env)->NewWeakGlobalRef(env, o);
7508         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
7509         CHECK(calls->type_id_meth != NULL);
7510         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
7511         CHECK(calls->debug_str_meth != NULL);
7512         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
7513         CHECK(calls->write_meth != NULL);
7514
7515         LDKType ret = {
7516                 .this_arg = (void*) calls,
7517                 .type_id = type_id_LDKType_jcall,
7518                 .debug_str = debug_str_LDKType_jcall,
7519                 .write = write_LDKType_jcall,
7520                 .cloned = LDKType_JCalls_cloned,
7521                 .free = LDKType_JCalls_free,
7522         };
7523         return ret;
7524 }
7525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
7526         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
7527         *res_ptr = LDKType_init(env, clz, o);
7528         return (uint64_t)res_ptr;
7529 }
7530 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
7531         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7532         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7533         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7534         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
7535         return ret_conv;
7536 }
7537
7538 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
7539         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7540         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7541         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7542         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
7543         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
7544         Str_free(ret_str);
7545         return ret_conv;
7546 }
7547
7548 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
7549         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7550         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7551         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7552         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
7553         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7554         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7555         CVec_u8Z_free(ret_var);
7556         return ret_arr;
7557 }
7558
7559 static jclass LDKCOption_TypeZ_Some_class = NULL;
7560 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
7561 static jclass LDKCOption_TypeZ_None_class = NULL;
7562 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
7563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
7564         LDKCOption_TypeZ_Some_class =
7565                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
7566         CHECK(LDKCOption_TypeZ_Some_class != NULL);
7567         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
7568         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
7569         LDKCOption_TypeZ_None_class =
7570                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
7571         CHECK(LDKCOption_TypeZ_None_class != NULL);
7572         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
7573         CHECK(LDKCOption_TypeZ_None_meth != NULL);
7574 }
7575 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7576         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
7577         switch(obj->tag) {
7578                 case LDKCOption_TypeZ_Some: {
7579                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
7580                         *some_ret = Type_clone(&obj->some);
7581                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (int64_t)some_ret);
7582                 }
7583                 case LDKCOption_TypeZ_None: {
7584                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
7585                 }
7586                 default: abort();
7587         }
7588 }
7589 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7590 CHECK(owner->result_ok);
7591         return COption_TypeZ_clone(&*owner->contents.result);
7592 }
7593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7594         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
7595         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
7596         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
7597         int64_t ret_ref = (uintptr_t)ret_copy;
7598         return ret_ref;
7599 }
7600
7601 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7602 CHECK(!owner->result_ok);
7603         return DecodeError_clone(&*owner->contents.err);
7604 }
7605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7606         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
7607         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
7608         int64_t ret_ref = 0;
7609         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7610         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7612         ret_ref = (uintptr_t)ret_var.inner;
7613         if (ret_var.is_owned) {
7614                 ret_ref |= 1;
7615         }
7616         return ret_ref;
7617 }
7618
7619 static jclass LDKPaymentError_Invoice_class = NULL;
7620 static jmethodID LDKPaymentError_Invoice_meth = NULL;
7621 static jclass LDKPaymentError_Routing_class = NULL;
7622 static jmethodID LDKPaymentError_Routing_meth = NULL;
7623 static jclass LDKPaymentError_Sending_class = NULL;
7624 static jmethodID LDKPaymentError_Sending_meth = NULL;
7625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
7626         LDKPaymentError_Invoice_class =
7627                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
7628         CHECK(LDKPaymentError_Invoice_class != NULL);
7629         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
7630         CHECK(LDKPaymentError_Invoice_meth != NULL);
7631         LDKPaymentError_Routing_class =
7632                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
7633         CHECK(LDKPaymentError_Routing_class != NULL);
7634         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
7635         CHECK(LDKPaymentError_Routing_meth != NULL);
7636         LDKPaymentError_Sending_class =
7637                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
7638         CHECK(LDKPaymentError_Sending_class != NULL);
7639         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
7640         CHECK(LDKPaymentError_Sending_meth != NULL);
7641 }
7642 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7643         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
7644         switch(obj->tag) {
7645                 case LDKPaymentError_Invoice: {
7646                         LDKStr invoice_str = obj->invoice;
7647                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
7648                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
7649                 }
7650                 case LDKPaymentError_Routing: {
7651                         LDKLightningError routing_var = obj->routing;
7652                         int64_t routing_ref = 0;
7653                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7654                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7655                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
7656                         routing_ref = (uintptr_t)routing_var.inner & ~1;
7657                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
7658                 }
7659                 case LDKPaymentError_Sending: {
7660                         int64_t sending_ref = ((uintptr_t)&obj->sending) | 1;
7661                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
7662                 }
7663                 default: abort();
7664         }
7665 }
7666 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
7667 CHECK(owner->result_ok);
7668         return ThirtyTwoBytes_clone(&*owner->contents.result);
7669 }
7670 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7671         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
7672         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7673         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
7674         return ret_arr;
7675 }
7676
7677 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
7678 CHECK(!owner->result_ok);
7679         return PaymentError_clone(&*owner->contents.err);
7680 }
7681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7682         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
7683         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
7684         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
7685         int64_t ret_ref = (uintptr_t)ret_copy;
7686         return ret_ref;
7687 }
7688
7689 static jclass LDKParseError_Bech32Error_class = NULL;
7690 static jmethodID LDKParseError_Bech32Error_meth = NULL;
7691 static jclass LDKParseError_ParseAmountError_class = NULL;
7692 static jmethodID LDKParseError_ParseAmountError_meth = NULL;
7693 static jclass LDKParseError_MalformedSignature_class = NULL;
7694 static jmethodID LDKParseError_MalformedSignature_meth = NULL;
7695 static jclass LDKParseError_BadPrefix_class = NULL;
7696 static jmethodID LDKParseError_BadPrefix_meth = NULL;
7697 static jclass LDKParseError_UnknownCurrency_class = NULL;
7698 static jmethodID LDKParseError_UnknownCurrency_meth = NULL;
7699 static jclass LDKParseError_UnknownSiPrefix_class = NULL;
7700 static jmethodID LDKParseError_UnknownSiPrefix_meth = NULL;
7701 static jclass LDKParseError_MalformedHRP_class = NULL;
7702 static jmethodID LDKParseError_MalformedHRP_meth = NULL;
7703 static jclass LDKParseError_TooShortDataPart_class = NULL;
7704 static jmethodID LDKParseError_TooShortDataPart_meth = NULL;
7705 static jclass LDKParseError_UnexpectedEndOfTaggedFields_class = NULL;
7706 static jmethodID LDKParseError_UnexpectedEndOfTaggedFields_meth = NULL;
7707 static jclass LDKParseError_DescriptionDecodeError_class = NULL;
7708 static jmethodID LDKParseError_DescriptionDecodeError_meth = NULL;
7709 static jclass LDKParseError_PaddingError_class = NULL;
7710 static jmethodID LDKParseError_PaddingError_meth = NULL;
7711 static jclass LDKParseError_IntegerOverflowError_class = NULL;
7712 static jmethodID LDKParseError_IntegerOverflowError_meth = NULL;
7713 static jclass LDKParseError_InvalidSegWitProgramLength_class = NULL;
7714 static jmethodID LDKParseError_InvalidSegWitProgramLength_meth = NULL;
7715 static jclass LDKParseError_InvalidPubKeyHashLength_class = NULL;
7716 static jmethodID LDKParseError_InvalidPubKeyHashLength_meth = NULL;
7717 static jclass LDKParseError_InvalidScriptHashLength_class = NULL;
7718 static jmethodID LDKParseError_InvalidScriptHashLength_meth = NULL;
7719 static jclass LDKParseError_InvalidRecoveryId_class = NULL;
7720 static jmethodID LDKParseError_InvalidRecoveryId_meth = NULL;
7721 static jclass LDKParseError_InvalidSliceLength_class = NULL;
7722 static jmethodID LDKParseError_InvalidSliceLength_meth = NULL;
7723 static jclass LDKParseError_Skip_class = NULL;
7724 static jmethodID LDKParseError_Skip_meth = NULL;
7725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseError_init (JNIEnv *env, jclass clz) {
7726         LDKParseError_Bech32Error_class =
7727                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Bech32Error"));
7728         CHECK(LDKParseError_Bech32Error_class != NULL);
7729         LDKParseError_Bech32Error_meth = (*env)->GetMethodID(env, LDKParseError_Bech32Error_class, "<init>", "(J)V");
7730         CHECK(LDKParseError_Bech32Error_meth != NULL);
7731         LDKParseError_ParseAmountError_class =
7732                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$ParseAmountError"));
7733         CHECK(LDKParseError_ParseAmountError_class != NULL);
7734         LDKParseError_ParseAmountError_meth = (*env)->GetMethodID(env, LDKParseError_ParseAmountError_class, "<init>", "(I)V");
7735         CHECK(LDKParseError_ParseAmountError_meth != NULL);
7736         LDKParseError_MalformedSignature_class =
7737                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedSignature"));
7738         CHECK(LDKParseError_MalformedSignature_class != NULL);
7739         LDKParseError_MalformedSignature_meth = (*env)->GetMethodID(env, LDKParseError_MalformedSignature_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
7740         CHECK(LDKParseError_MalformedSignature_meth != NULL);
7741         LDKParseError_BadPrefix_class =
7742                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$BadPrefix"));
7743         CHECK(LDKParseError_BadPrefix_class != NULL);
7744         LDKParseError_BadPrefix_meth = (*env)->GetMethodID(env, LDKParseError_BadPrefix_class, "<init>", "()V");
7745         CHECK(LDKParseError_BadPrefix_meth != NULL);
7746         LDKParseError_UnknownCurrency_class =
7747                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownCurrency"));
7748         CHECK(LDKParseError_UnknownCurrency_class != NULL);
7749         LDKParseError_UnknownCurrency_meth = (*env)->GetMethodID(env, LDKParseError_UnknownCurrency_class, "<init>", "()V");
7750         CHECK(LDKParseError_UnknownCurrency_meth != NULL);
7751         LDKParseError_UnknownSiPrefix_class =
7752                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownSiPrefix"));
7753         CHECK(LDKParseError_UnknownSiPrefix_class != NULL);
7754         LDKParseError_UnknownSiPrefix_meth = (*env)->GetMethodID(env, LDKParseError_UnknownSiPrefix_class, "<init>", "()V");
7755         CHECK(LDKParseError_UnknownSiPrefix_meth != NULL);
7756         LDKParseError_MalformedHRP_class =
7757                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedHRP"));
7758         CHECK(LDKParseError_MalformedHRP_class != NULL);
7759         LDKParseError_MalformedHRP_meth = (*env)->GetMethodID(env, LDKParseError_MalformedHRP_class, "<init>", "()V");
7760         CHECK(LDKParseError_MalformedHRP_meth != NULL);
7761         LDKParseError_TooShortDataPart_class =
7762                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$TooShortDataPart"));
7763         CHECK(LDKParseError_TooShortDataPart_class != NULL);
7764         LDKParseError_TooShortDataPart_meth = (*env)->GetMethodID(env, LDKParseError_TooShortDataPart_class, "<init>", "()V");
7765         CHECK(LDKParseError_TooShortDataPart_meth != NULL);
7766         LDKParseError_UnexpectedEndOfTaggedFields_class =
7767                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnexpectedEndOfTaggedFields"));
7768         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_class != NULL);
7769         LDKParseError_UnexpectedEndOfTaggedFields_meth = (*env)->GetMethodID(env, LDKParseError_UnexpectedEndOfTaggedFields_class, "<init>", "()V");
7770         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_meth != NULL);
7771         LDKParseError_DescriptionDecodeError_class =
7772                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$DescriptionDecodeError"));
7773         CHECK(LDKParseError_DescriptionDecodeError_class != NULL);
7774         LDKParseError_DescriptionDecodeError_meth = (*env)->GetMethodID(env, LDKParseError_DescriptionDecodeError_class, "<init>", "(I)V");
7775         CHECK(LDKParseError_DescriptionDecodeError_meth != NULL);
7776         LDKParseError_PaddingError_class =
7777                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$PaddingError"));
7778         CHECK(LDKParseError_PaddingError_class != NULL);
7779         LDKParseError_PaddingError_meth = (*env)->GetMethodID(env, LDKParseError_PaddingError_class, "<init>", "()V");
7780         CHECK(LDKParseError_PaddingError_meth != NULL);
7781         LDKParseError_IntegerOverflowError_class =
7782                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$IntegerOverflowError"));
7783         CHECK(LDKParseError_IntegerOverflowError_class != NULL);
7784         LDKParseError_IntegerOverflowError_meth = (*env)->GetMethodID(env, LDKParseError_IntegerOverflowError_class, "<init>", "()V");
7785         CHECK(LDKParseError_IntegerOverflowError_meth != NULL);
7786         LDKParseError_InvalidSegWitProgramLength_class =
7787                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSegWitProgramLength"));
7788         CHECK(LDKParseError_InvalidSegWitProgramLength_class != NULL);
7789         LDKParseError_InvalidSegWitProgramLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSegWitProgramLength_class, "<init>", "()V");
7790         CHECK(LDKParseError_InvalidSegWitProgramLength_meth != NULL);
7791         LDKParseError_InvalidPubKeyHashLength_class =
7792                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidPubKeyHashLength"));
7793         CHECK(LDKParseError_InvalidPubKeyHashLength_class != NULL);
7794         LDKParseError_InvalidPubKeyHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidPubKeyHashLength_class, "<init>", "()V");
7795         CHECK(LDKParseError_InvalidPubKeyHashLength_meth != NULL);
7796         LDKParseError_InvalidScriptHashLength_class =
7797                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidScriptHashLength"));
7798         CHECK(LDKParseError_InvalidScriptHashLength_class != NULL);
7799         LDKParseError_InvalidScriptHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidScriptHashLength_class, "<init>", "()V");
7800         CHECK(LDKParseError_InvalidScriptHashLength_meth != NULL);
7801         LDKParseError_InvalidRecoveryId_class =
7802                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidRecoveryId"));
7803         CHECK(LDKParseError_InvalidRecoveryId_class != NULL);
7804         LDKParseError_InvalidRecoveryId_meth = (*env)->GetMethodID(env, LDKParseError_InvalidRecoveryId_class, "<init>", "()V");
7805         CHECK(LDKParseError_InvalidRecoveryId_meth != NULL);
7806         LDKParseError_InvalidSliceLength_class =
7807                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSliceLength"));
7808         CHECK(LDKParseError_InvalidSliceLength_class != NULL);
7809         LDKParseError_InvalidSliceLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSliceLength_class, "<init>", "(Ljava/lang/String;)V");
7810         CHECK(LDKParseError_InvalidSliceLength_meth != NULL);
7811         LDKParseError_Skip_class =
7812                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Skip"));
7813         CHECK(LDKParseError_Skip_class != NULL);
7814         LDKParseError_Skip_meth = (*env)->GetMethodID(env, LDKParseError_Skip_class, "<init>", "()V");
7815         CHECK(LDKParseError_Skip_meth != NULL);
7816 }
7817 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7818         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
7819         switch(obj->tag) {
7820                 case LDKParseError_Bech32Error: {
7821                         int64_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
7822                         return (*env)->NewObject(env, LDKParseError_Bech32Error_class, LDKParseError_Bech32Error_meth, bech32_error_ref);
7823                 }
7824                 case LDKParseError_ParseAmountError: {
7825                         /*obj->parse_amount_error*/
7826                         return (*env)->NewObject(env, LDKParseError_ParseAmountError_class, LDKParseError_ParseAmountError_meth, 0);
7827                 }
7828                 case LDKParseError_MalformedSignature: {
7829                         jclass malformed_signature_conv = LDKSecp256k1Error_to_java(env, obj->malformed_signature);
7830                         return (*env)->NewObject(env, LDKParseError_MalformedSignature_class, LDKParseError_MalformedSignature_meth, malformed_signature_conv);
7831                 }
7832                 case LDKParseError_BadPrefix: {
7833                         return (*env)->NewObject(env, LDKParseError_BadPrefix_class, LDKParseError_BadPrefix_meth);
7834                 }
7835                 case LDKParseError_UnknownCurrency: {
7836                         return (*env)->NewObject(env, LDKParseError_UnknownCurrency_class, LDKParseError_UnknownCurrency_meth);
7837                 }
7838                 case LDKParseError_UnknownSiPrefix: {
7839                         return (*env)->NewObject(env, LDKParseError_UnknownSiPrefix_class, LDKParseError_UnknownSiPrefix_meth);
7840                 }
7841                 case LDKParseError_MalformedHRP: {
7842                         return (*env)->NewObject(env, LDKParseError_MalformedHRP_class, LDKParseError_MalformedHRP_meth);
7843                 }
7844                 case LDKParseError_TooShortDataPart: {
7845                         return (*env)->NewObject(env, LDKParseError_TooShortDataPart_class, LDKParseError_TooShortDataPart_meth);
7846                 }
7847                 case LDKParseError_UnexpectedEndOfTaggedFields: {
7848                         return (*env)->NewObject(env, LDKParseError_UnexpectedEndOfTaggedFields_class, LDKParseError_UnexpectedEndOfTaggedFields_meth);
7849                 }
7850                 case LDKParseError_DescriptionDecodeError: {
7851                         /*obj->description_decode_error*/
7852                         return (*env)->NewObject(env, LDKParseError_DescriptionDecodeError_class, LDKParseError_DescriptionDecodeError_meth, 0);
7853                 }
7854                 case LDKParseError_PaddingError: {
7855                         return (*env)->NewObject(env, LDKParseError_PaddingError_class, LDKParseError_PaddingError_meth);
7856                 }
7857                 case LDKParseError_IntegerOverflowError: {
7858                         return (*env)->NewObject(env, LDKParseError_IntegerOverflowError_class, LDKParseError_IntegerOverflowError_meth);
7859                 }
7860                 case LDKParseError_InvalidSegWitProgramLength: {
7861                         return (*env)->NewObject(env, LDKParseError_InvalidSegWitProgramLength_class, LDKParseError_InvalidSegWitProgramLength_meth);
7862                 }
7863                 case LDKParseError_InvalidPubKeyHashLength: {
7864                         return (*env)->NewObject(env, LDKParseError_InvalidPubKeyHashLength_class, LDKParseError_InvalidPubKeyHashLength_meth);
7865                 }
7866                 case LDKParseError_InvalidScriptHashLength: {
7867                         return (*env)->NewObject(env, LDKParseError_InvalidScriptHashLength_class, LDKParseError_InvalidScriptHashLength_meth);
7868                 }
7869                 case LDKParseError_InvalidRecoveryId: {
7870                         return (*env)->NewObject(env, LDKParseError_InvalidRecoveryId_class, LDKParseError_InvalidRecoveryId_meth);
7871                 }
7872                 case LDKParseError_InvalidSliceLength: {
7873                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
7874                         jstring invalid_slice_length_conv = str_ref_to_java(env, invalid_slice_length_str.chars, invalid_slice_length_str.len);
7875                         return (*env)->NewObject(env, LDKParseError_InvalidSliceLength_class, LDKParseError_InvalidSliceLength_meth, invalid_slice_length_conv);
7876                 }
7877                 case LDKParseError_Skip: {
7878                         return (*env)->NewObject(env, LDKParseError_Skip_class, LDKParseError_Skip_meth);
7879                 }
7880                 default: abort();
7881         }
7882 }
7883 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
7884 CHECK(owner->result_ok);
7885         return SiPrefix_clone(&*owner->contents.result);
7886 }
7887 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7888         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
7889         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
7890         return ret_conv;
7891 }
7892
7893 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
7894 CHECK(!owner->result_ok);
7895         return ParseError_clone(&*owner->contents.err);
7896 }
7897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7898         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
7899         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
7900         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
7901         int64_t ret_ref = (uintptr_t)ret_copy;
7902         return ret_ref;
7903 }
7904
7905 static jclass LDKParseOrSemanticError_ParseError_class = NULL;
7906 static jmethodID LDKParseOrSemanticError_ParseError_meth = NULL;
7907 static jclass LDKParseOrSemanticError_SemanticError_class = NULL;
7908 static jmethodID LDKParseOrSemanticError_SemanticError_meth = NULL;
7909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseOrSemanticError_init (JNIEnv *env, jclass clz) {
7910         LDKParseOrSemanticError_ParseError_class =
7911                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$ParseError"));
7912         CHECK(LDKParseOrSemanticError_ParseError_class != NULL);
7913         LDKParseOrSemanticError_ParseError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_ParseError_class, "<init>", "(J)V");
7914         CHECK(LDKParseOrSemanticError_ParseError_meth != NULL);
7915         LDKParseOrSemanticError_SemanticError_class =
7916                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$SemanticError"));
7917         CHECK(LDKParseOrSemanticError_SemanticError_class != NULL);
7918         LDKParseOrSemanticError_SemanticError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_SemanticError_class, "<init>", "(Lorg/ldk/enums/SemanticError;)V");
7919         CHECK(LDKParseOrSemanticError_SemanticError_meth != NULL);
7920 }
7921 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseOrSemanticError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7922         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
7923         switch(obj->tag) {
7924                 case LDKParseOrSemanticError_ParseError: {
7925                         int64_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
7926                         return (*env)->NewObject(env, LDKParseOrSemanticError_ParseError_class, LDKParseOrSemanticError_ParseError_meth, parse_error_ref);
7927                 }
7928                 case LDKParseOrSemanticError_SemanticError: {
7929                         jclass semantic_error_conv = LDKSemanticError_to_java(env, obj->semantic_error);
7930                         return (*env)->NewObject(env, LDKParseOrSemanticError_SemanticError_class, LDKParseOrSemanticError_SemanticError_meth, semantic_error_conv);
7931                 }
7932                 default: abort();
7933         }
7934 }
7935 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7936 CHECK(owner->result_ok);
7937         return Invoice_clone(&*owner->contents.result);
7938 }
7939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7940         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
7941         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
7942         int64_t ret_ref = 0;
7943         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7944         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7946         ret_ref = (uintptr_t)ret_var.inner;
7947         if (ret_var.is_owned) {
7948                 ret_ref |= 1;
7949         }
7950         return ret_ref;
7951 }
7952
7953 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7954 CHECK(!owner->result_ok);
7955         return ParseOrSemanticError_clone(&*owner->contents.err);
7956 }
7957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7958         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
7959         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
7960         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
7961         int64_t ret_ref = (uintptr_t)ret_copy;
7962         return ret_ref;
7963 }
7964
7965 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7966 CHECK(owner->result_ok);
7967         return SignedRawInvoice_clone(&*owner->contents.result);
7968 }
7969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7970         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
7971         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
7972         int64_t ret_ref = 0;
7973         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7974         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7976         ret_ref = (uintptr_t)ret_var.inner;
7977         if (ret_var.is_owned) {
7978                 ret_ref |= 1;
7979         }
7980         return ret_ref;
7981 }
7982
7983 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7984 CHECK(!owner->result_ok);
7985         return ParseError_clone(&*owner->contents.err);
7986 }
7987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7988         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
7989         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
7990         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
7991         int64_t ret_ref = (uintptr_t)ret_copy;
7992         return ret_ref;
7993 }
7994
7995 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7996         return RawInvoice_clone(&owner->a);
7997 }
7998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7999         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
8000         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
8001         int64_t ret_ref = 0;
8002         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8003         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8005         ret_ref = (uintptr_t)ret_var.inner;
8006         if (ret_var.is_owned) {
8007                 ret_ref |= 1;
8008         }
8009         return ret_ref;
8010 }
8011
8012 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
8013         return ThirtyTwoBytes_clone(&owner->b);
8014 }
8015 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8016         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
8017         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8018         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
8019         return ret_arr;
8020 }
8021
8022 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
8023         return InvoiceSignature_clone(&owner->c);
8024 }
8025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
8026         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
8027         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(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 LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
8040 CHECK(owner->result_ok);
8041         return PayeePubKey_clone(&*owner->contents.result);
8042 }
8043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8044         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
8045         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(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 enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
8058 CHECK(!owner->result_ok);
8059         return *owner->contents.err;
8060 }
8061 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8062         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
8063         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
8064         return ret_conv;
8065 }
8066
8067 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
8068         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
8069         for (size_t i = 0; i < ret.datalen; i++) {
8070                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
8071         }
8072         return ret;
8073 }
8074 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
8075 CHECK(owner->result_ok);
8076         return PositiveTimestamp_clone(&*owner->contents.result);
8077 }
8078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8079         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
8080         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
8081         int64_t ret_ref = 0;
8082         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8083         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8085         ret_ref = (uintptr_t)ret_var.inner;
8086         if (ret_var.is_owned) {
8087                 ret_ref |= 1;
8088         }
8089         return ret_ref;
8090 }
8091
8092 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
8093 CHECK(!owner->result_ok);
8094         return CreationError_clone(&*owner->contents.err);
8095 }
8096 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8097         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
8098         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
8099         return ret_conv;
8100 }
8101
8102 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
8103 CHECK(owner->result_ok);
8104         return *owner->contents.result;
8105 }
8106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8107         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
8108         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
8109 }
8110
8111 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
8112 CHECK(!owner->result_ok);
8113         return SemanticError_clone(&*owner->contents.err);
8114 }
8115 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8116         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
8117         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
8118         return ret_conv;
8119 }
8120
8121 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
8122 CHECK(owner->result_ok);
8123         return Invoice_clone(&*owner->contents.result);
8124 }
8125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8126         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
8127         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
8128         int64_t ret_ref = 0;
8129         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8130         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8132         ret_ref = (uintptr_t)ret_var.inner;
8133         if (ret_var.is_owned) {
8134                 ret_ref |= 1;
8135         }
8136         return ret_ref;
8137 }
8138
8139 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
8140 CHECK(!owner->result_ok);
8141         return SemanticError_clone(&*owner->contents.err);
8142 }
8143 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8144         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
8145         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
8146         return ret_conv;
8147 }
8148
8149 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
8150 CHECK(owner->result_ok);
8151         return Description_clone(&*owner->contents.result);
8152 }
8153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8154         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
8155         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
8156         int64_t ret_ref = 0;
8157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8160         ret_ref = (uintptr_t)ret_var.inner;
8161         if (ret_var.is_owned) {
8162                 ret_ref |= 1;
8163         }
8164         return ret_ref;
8165 }
8166
8167 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
8168 CHECK(!owner->result_ok);
8169         return CreationError_clone(&*owner->contents.err);
8170 }
8171 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8172         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
8173         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
8174         return ret_conv;
8175 }
8176
8177 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
8178 CHECK(owner->result_ok);
8179         return PrivateRoute_clone(&*owner->contents.result);
8180 }
8181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8182         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
8183         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
8184         int64_t ret_ref = 0;
8185         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8186         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8188         ret_ref = (uintptr_t)ret_var.inner;
8189         if (ret_var.is_owned) {
8190                 ret_ref |= 1;
8191         }
8192         return ret_ref;
8193 }
8194
8195 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
8196 CHECK(!owner->result_ok);
8197         return CreationError_clone(&*owner->contents.err);
8198 }
8199 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8200         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
8201         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
8202         return ret_conv;
8203 }
8204
8205 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8206 CHECK(owner->result_ok);
8207         return *owner->contents.result;
8208 }
8209 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8210         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
8211         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
8212         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8213         return ret_conv;
8214 }
8215
8216 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8217 CHECK(!owner->result_ok);
8218         return *owner->contents.err;
8219 }
8220 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8221         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
8222         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
8223         return ret_conv;
8224 }
8225
8226 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8227 CHECK(owner->result_ok);
8228         return ChannelMonitorUpdate_clone(&*owner->contents.result);
8229 }
8230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8231         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
8232         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
8233         int64_t ret_ref = 0;
8234         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8235         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8237         ret_ref = (uintptr_t)ret_var.inner;
8238         if (ret_var.is_owned) {
8239                 ret_ref |= 1;
8240         }
8241         return ret_ref;
8242 }
8243
8244 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8245 CHECK(!owner->result_ok);
8246         return DecodeError_clone(&*owner->contents.err);
8247 }
8248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8249         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
8250         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
8251         int64_t ret_ref = 0;
8252         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8253         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8255         ret_ref = (uintptr_t)ret_var.inner;
8256         if (ret_var.is_owned) {
8257                 ret_ref |= 1;
8258         }
8259         return ret_ref;
8260 }
8261
8262 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
8263 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
8264 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
8265 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
8266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
8267         LDKCOption_MonitorEventZ_Some_class =
8268                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
8269         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
8270         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
8271         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
8272         LDKCOption_MonitorEventZ_None_class =
8273                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
8274         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
8275         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
8276         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
8277 }
8278 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8279         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
8280         switch(obj->tag) {
8281                 case LDKCOption_MonitorEventZ_Some: {
8282                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
8283                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
8284                 }
8285                 case LDKCOption_MonitorEventZ_None: {
8286                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
8287                 }
8288                 default: abort();
8289         }
8290 }
8291 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8292 CHECK(owner->result_ok);
8293         return COption_MonitorEventZ_clone(&*owner->contents.result);
8294 }
8295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8296         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
8297         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
8298         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
8299         int64_t ret_ref = (uintptr_t)ret_copy;
8300         return ret_ref;
8301 }
8302
8303 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8304 CHECK(!owner->result_ok);
8305         return DecodeError_clone(&*owner->contents.err);
8306 }
8307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8308         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
8309         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
8310         int64_t ret_ref = 0;
8311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8314         ret_ref = (uintptr_t)ret_var.inner;
8315         if (ret_var.is_owned) {
8316                 ret_ref |= 1;
8317         }
8318         return ret_ref;
8319 }
8320
8321 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8322 CHECK(owner->result_ok);
8323         return HTLCUpdate_clone(&*owner->contents.result);
8324 }
8325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8326         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
8327         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
8328         int64_t ret_ref = 0;
8329         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8330         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8332         ret_ref = (uintptr_t)ret_var.inner;
8333         if (ret_var.is_owned) {
8334                 ret_ref |= 1;
8335         }
8336         return ret_ref;
8337 }
8338
8339 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8340 CHECK(!owner->result_ok);
8341         return DecodeError_clone(&*owner->contents.err);
8342 }
8343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8344         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
8345         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
8346         int64_t ret_ref = 0;
8347         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8348         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8350         ret_ref = (uintptr_t)ret_var.inner;
8351         if (ret_var.is_owned) {
8352                 ret_ref |= 1;
8353         }
8354         return ret_ref;
8355 }
8356
8357 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8358         return OutPoint_clone(&owner->a);
8359 }
8360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8361         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
8362         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
8363         int64_t ret_ref = 0;
8364         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8365         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8367         ret_ref = (uintptr_t)ret_var.inner;
8368         if (ret_var.is_owned) {
8369                 ret_ref |= 1;
8370         }
8371         return ret_ref;
8372 }
8373
8374 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8375         return CVec_u8Z_clone(&owner->b);
8376 }
8377 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8378         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
8379         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
8380         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8381         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8382         CVec_u8Z_free(ret_var);
8383         return ret_arr;
8384 }
8385
8386 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8387         return owner->a;
8388 }
8389 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8390         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
8391         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
8392         return ret_conv;
8393 }
8394
8395 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8396         return CVec_u8Z_clone(&owner->b);
8397 }
8398 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8399         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
8400         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
8401         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8402         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8403         CVec_u8Z_free(ret_var);
8404         return ret_arr;
8405 }
8406
8407 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
8408         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
8409         for (size_t i = 0; i < ret.datalen; i++) {
8410                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
8411         }
8412         return ret;
8413 }
8414 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8415         return ThirtyTwoBytes_clone(&owner->a);
8416 }
8417 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8418         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
8419         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8420         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
8421         return ret_arr;
8422 }
8423
8424 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8425         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
8426 }
8427 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8428         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
8429         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
8430         int64_tArray ret_arr = NULL;
8431         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8432         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8433         for (size_t v = 0; v < ret_var.datalen; v++) {
8434                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8435                 *ret_conv_21_conv = ret_var.data[v];
8436                 ret_arr_ptr[v] = ((int64_t)ret_conv_21_conv);
8437         }
8438         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8439         FREE(ret_var.data);
8440         return ret_arr;
8441 }
8442
8443 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
8444         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 };
8445         for (size_t i = 0; i < ret.datalen; i++) {
8446                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
8447         }
8448         return ret;
8449 }
8450 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
8451         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
8452         for (size_t i = 0; i < ret.datalen; i++) {
8453                 ret.data[i] = Event_clone(&orig->data[i]);
8454         }
8455         return ret;
8456 }
8457 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8458         return owner->a;
8459 }
8460 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8461         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
8462         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
8463         return ret_conv;
8464 }
8465
8466 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8467         return TxOut_clone(&owner->b);
8468 }
8469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8470         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
8471         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8472         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
8473         return (int64_t)ret_ref;
8474 }
8475
8476 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
8477         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
8478         for (size_t i = 0; i < ret.datalen; i++) {
8479                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
8480         }
8481         return ret;
8482 }
8483 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8484         return ThirtyTwoBytes_clone(&owner->a);
8485 }
8486 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8487         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
8488         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8489         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
8490         return ret_arr;
8491 }
8492
8493 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8494         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
8495 }
8496 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8497         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
8498         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
8499         int64_tArray ret_arr = NULL;
8500         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8501         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8502         for (size_t u = 0; u < ret_var.datalen; u++) {
8503                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8504                 *ret_conv_20_conv = ret_var.data[u];
8505                 ret_arr_ptr[u] = ((int64_t)ret_conv_20_conv);
8506         }
8507         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8508         FREE(ret_var.data);
8509         return ret_arr;
8510 }
8511
8512 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
8513         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 };
8514         for (size_t i = 0; i < ret.datalen; i++) {
8515                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
8516         }
8517         return ret;
8518 }
8519 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
8520 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
8521 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
8522 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
8523 static jclass LDKBalance_ContentiousClaimable_class = NULL;
8524 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
8525 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
8526 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
8527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
8528         LDKBalance_ClaimableOnChannelClose_class =
8529                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
8530         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
8531         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
8532         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
8533         LDKBalance_ClaimableAwaitingConfirmations_class =
8534                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
8535         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
8536         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
8537         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
8538         LDKBalance_ContentiousClaimable_class =
8539                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
8540         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
8541         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
8542         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
8543         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
8544                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout"));
8545         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
8546         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
8547         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
8548 }
8549 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8550         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
8551         switch(obj->tag) {
8552                 case LDKBalance_ClaimableOnChannelClose: {
8553                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
8554                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, claimable_amount_satoshis_conv);
8555                 }
8556                 case LDKBalance_ClaimableAwaitingConfirmations: {
8557                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
8558                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
8559                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, claimable_amount_satoshis_conv, confirmation_height_conv);
8560                 }
8561                 case LDKBalance_ContentiousClaimable: {
8562                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
8563                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
8564                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, claimable_amount_satoshis_conv, timeout_height_conv);
8565                 }
8566                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
8567                         int64_t claimable_amount_satoshis_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
8568                         int32_t claimable_height_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
8569                         return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, claimable_amount_satoshis_conv, claimable_height_conv);
8570                 }
8571                 default: abort();
8572         }
8573 }
8574 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
8575         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
8576         for (size_t i = 0; i < ret.datalen; i++) {
8577                 ret.data[i] = Balance_clone(&orig->data[i]);
8578         }
8579         return ret;
8580 }
8581 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8582 CHECK(owner->result_ok);
8583         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
8584 }
8585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8586         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
8587         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
8588         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
8589         return ((int64_t)ret_conv);
8590 }
8591
8592 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8593 CHECK(!owner->result_ok);
8594         return DecodeError_clone(&*owner->contents.err);
8595 }
8596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8597         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
8598         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
8599         int64_t ret_ref = 0;
8600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8603         ret_ref = (uintptr_t)ret_var.inner;
8604         if (ret_var.is_owned) {
8605                 ret_ref |= 1;
8606         }
8607         return ret_ref;
8608 }
8609
8610 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8611         return owner->a;
8612 }
8613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8614         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
8615         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
8616         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
8617         return ret_arr;
8618 }
8619
8620 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8621         return Type_clone(&owner->b);
8622 }
8623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8624         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
8625         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
8626         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
8627         return (int64_t)ret_ret;
8628 }
8629
8630 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
8631         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
8632         for (size_t i = 0; i < ret.datalen; i++) {
8633                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
8634         }
8635         return ret;
8636 }
8637 static jclass LDKCOption_NetAddressZ_Some_class = NULL;
8638 static jmethodID LDKCOption_NetAddressZ_Some_meth = NULL;
8639 static jclass LDKCOption_NetAddressZ_None_class = NULL;
8640 static jmethodID LDKCOption_NetAddressZ_None_meth = NULL;
8641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetAddressZ_init (JNIEnv *env, jclass clz) {
8642         LDKCOption_NetAddressZ_Some_class =
8643                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$Some"));
8644         CHECK(LDKCOption_NetAddressZ_Some_class != NULL);
8645         LDKCOption_NetAddressZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_Some_class, "<init>", "(J)V");
8646         CHECK(LDKCOption_NetAddressZ_Some_meth != NULL);
8647         LDKCOption_NetAddressZ_None_class =
8648                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$None"));
8649         CHECK(LDKCOption_NetAddressZ_None_class != NULL);
8650         LDKCOption_NetAddressZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_None_class, "<init>", "()V");
8651         CHECK(LDKCOption_NetAddressZ_None_meth != NULL);
8652 }
8653 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetAddressZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8654         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
8655         switch(obj->tag) {
8656                 case LDKCOption_NetAddressZ_Some: {
8657                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
8658                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_Some_class, LDKCOption_NetAddressZ_Some_meth, some_ref);
8659                 }
8660                 case LDKCOption_NetAddressZ_None: {
8661                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_None_class, LDKCOption_NetAddressZ_None_meth);
8662                 }
8663                 default: abort();
8664         }
8665 }
8666 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
8667 CHECK(owner->result_ok);
8668         return CVec_u8Z_clone(&*owner->contents.result);
8669 }
8670 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8671         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
8672         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
8673         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8674         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8675         CVec_u8Z_free(ret_var);
8676         return ret_arr;
8677 }
8678
8679 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
8680 CHECK(!owner->result_ok);
8681         return PeerHandleError_clone(&*owner->contents.err);
8682 }
8683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8684         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
8685         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
8686         int64_t ret_ref = 0;
8687         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8688         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8690         ret_ref = (uintptr_t)ret_var.inner;
8691         if (ret_var.is_owned) {
8692                 ret_ref |= 1;
8693         }
8694         return ret_ref;
8695 }
8696
8697 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8698 CHECK(owner->result_ok);
8699         return *owner->contents.result;
8700 }
8701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8702         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
8703         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
8704 }
8705
8706 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8707 CHECK(!owner->result_ok);
8708         return PeerHandleError_clone(&*owner->contents.err);
8709 }
8710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8711         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
8712         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
8713         int64_t ret_ref = 0;
8714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8717         ret_ref = (uintptr_t)ret_var.inner;
8718         if (ret_var.is_owned) {
8719                 ret_ref |= 1;
8720         }
8721         return ret_ref;
8722 }
8723
8724 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
8725 CHECK(owner->result_ok);
8726         return *owner->contents.result;
8727 }
8728 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8729         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
8730         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
8731         return ret_conv;
8732 }
8733
8734 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
8735 CHECK(!owner->result_ok);
8736         return PeerHandleError_clone(&*owner->contents.err);
8737 }
8738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8739         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
8740         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_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 jclass LDKGraphSyncError_DecodeError_class = NULL;
8753 static jmethodID LDKGraphSyncError_DecodeError_meth = NULL;
8754 static jclass LDKGraphSyncError_LightningError_class = NULL;
8755 static jmethodID LDKGraphSyncError_LightningError_meth = NULL;
8756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGraphSyncError_init (JNIEnv *env, jclass clz) {
8757         LDKGraphSyncError_DecodeError_class =
8758                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$DecodeError"));
8759         CHECK(LDKGraphSyncError_DecodeError_class != NULL);
8760         LDKGraphSyncError_DecodeError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_DecodeError_class, "<init>", "(J)V");
8761         CHECK(LDKGraphSyncError_DecodeError_meth != NULL);
8762         LDKGraphSyncError_LightningError_class =
8763                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$LightningError"));
8764         CHECK(LDKGraphSyncError_LightningError_class != NULL);
8765         LDKGraphSyncError_LightningError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_LightningError_class, "<init>", "(J)V");
8766         CHECK(LDKGraphSyncError_LightningError_meth != NULL);
8767 }
8768 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGraphSyncError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8769         LDKGraphSyncError *obj = (LDKGraphSyncError*)(ptr & ~1);
8770         switch(obj->tag) {
8771                 case LDKGraphSyncError_DecodeError: {
8772                         LDKDecodeError decode_error_var = obj->decode_error;
8773                         int64_t decode_error_ref = 0;
8774                         CHECK((((uintptr_t)decode_error_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8775                         CHECK((((uintptr_t)&decode_error_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8776                         CHECK_INNER_FIELD_ACCESS_OR_NULL(decode_error_var);
8777                         decode_error_ref = (uintptr_t)decode_error_var.inner & ~1;
8778                         return (*env)->NewObject(env, LDKGraphSyncError_DecodeError_class, LDKGraphSyncError_DecodeError_meth, decode_error_ref);
8779                 }
8780                 case LDKGraphSyncError_LightningError: {
8781                         LDKLightningError lightning_error_var = obj->lightning_error;
8782                         int64_t lightning_error_ref = 0;
8783                         CHECK((((uintptr_t)lightning_error_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8784                         CHECK((((uintptr_t)&lightning_error_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8785                         CHECK_INNER_FIELD_ACCESS_OR_NULL(lightning_error_var);
8786                         lightning_error_ref = (uintptr_t)lightning_error_var.inner & ~1;
8787                         return (*env)->NewObject(env, LDKGraphSyncError_LightningError_class, LDKGraphSyncError_LightningError_meth, lightning_error_ref);
8788                 }
8789                 default: abort();
8790         }
8791 }
8792 static inline uint32_t CResult_u32GraphSyncErrorZ_get_ok(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
8793 CHECK(owner->result_ok);
8794         return *owner->contents.result;
8795 }
8796 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8797         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)(owner & ~1);
8798         int32_t ret_conv = CResult_u32GraphSyncErrorZ_get_ok(owner_conv);
8799         return ret_conv;
8800 }
8801
8802 static inline struct LDKGraphSyncError CResult_u32GraphSyncErrorZ_get_err(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
8803 CHECK(!owner->result_ok);
8804         return GraphSyncError_clone(&*owner->contents.err);
8805 }
8806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8807         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)(owner & ~1);
8808         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
8809         *ret_copy = CResult_u32GraphSyncErrorZ_get_err(owner_conv);
8810         int64_t ret_ref = (uintptr_t)ret_copy;
8811         return ret_ref;
8812 }
8813
8814 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8815 CHECK(owner->result_ok);
8816         return NetAddress_clone(&*owner->contents.result);
8817 }
8818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8819         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8820         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
8821         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
8822         int64_t ret_ref = (uintptr_t)ret_copy;
8823         return ret_ref;
8824 }
8825
8826 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8827 CHECK(!owner->result_ok);
8828         return DecodeError_clone(&*owner->contents.err);
8829 }
8830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8831         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8832         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
8833         int64_t ret_ref = 0;
8834         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8835         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8837         ret_ref = (uintptr_t)ret_var.inner;
8838         if (ret_var.is_owned) {
8839                 ret_ref |= 1;
8840         }
8841         return ret_ref;
8842 }
8843
8844 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
8845         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
8846         for (size_t i = 0; i < ret.datalen; i++) {
8847                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
8848         }
8849         return ret;
8850 }
8851 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
8852         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
8853         for (size_t i = 0; i < ret.datalen; i++) {
8854                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
8855         }
8856         return ret;
8857 }
8858 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
8859         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
8860         for (size_t i = 0; i < ret.datalen; i++) {
8861                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
8862         }
8863         return ret;
8864 }
8865 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
8866         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
8867         for (size_t i = 0; i < ret.datalen; i++) {
8868                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
8869         }
8870         return ret;
8871 }
8872 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8873 CHECK(owner->result_ok);
8874         return AcceptChannel_clone(&*owner->contents.result);
8875 }
8876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8877         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8878         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
8879         int64_t ret_ref = 0;
8880         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8881         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8883         ret_ref = (uintptr_t)ret_var.inner;
8884         if (ret_var.is_owned) {
8885                 ret_ref |= 1;
8886         }
8887         return ret_ref;
8888 }
8889
8890 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8891 CHECK(!owner->result_ok);
8892         return DecodeError_clone(&*owner->contents.err);
8893 }
8894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8895         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8896         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
8897         int64_t ret_ref = 0;
8898         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8899         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8901         ret_ref = (uintptr_t)ret_var.inner;
8902         if (ret_var.is_owned) {
8903                 ret_ref |= 1;
8904         }
8905         return ret_ref;
8906 }
8907
8908 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8909 CHECK(owner->result_ok);
8910         return AnnouncementSignatures_clone(&*owner->contents.result);
8911 }
8912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8913         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8914         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
8915         int64_t ret_ref = 0;
8916         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8917         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8918         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8919         ret_ref = (uintptr_t)ret_var.inner;
8920         if (ret_var.is_owned) {
8921                 ret_ref |= 1;
8922         }
8923         return ret_ref;
8924 }
8925
8926 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8927 CHECK(!owner->result_ok);
8928         return DecodeError_clone(&*owner->contents.err);
8929 }
8930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8931         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8932         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
8933         int64_t ret_ref = 0;
8934         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8935         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8937         ret_ref = (uintptr_t)ret_var.inner;
8938         if (ret_var.is_owned) {
8939                 ret_ref |= 1;
8940         }
8941         return ret_ref;
8942 }
8943
8944 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8945 CHECK(owner->result_ok);
8946         return ChannelReestablish_clone(&*owner->contents.result);
8947 }
8948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8949         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8950         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
8951         int64_t ret_ref = 0;
8952         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8953         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8954         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8955         ret_ref = (uintptr_t)ret_var.inner;
8956         if (ret_var.is_owned) {
8957                 ret_ref |= 1;
8958         }
8959         return ret_ref;
8960 }
8961
8962 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8963 CHECK(!owner->result_ok);
8964         return DecodeError_clone(&*owner->contents.err);
8965 }
8966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8967         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8968         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
8969         int64_t ret_ref = 0;
8970         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8971         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8972         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8973         ret_ref = (uintptr_t)ret_var.inner;
8974         if (ret_var.is_owned) {
8975                 ret_ref |= 1;
8976         }
8977         return ret_ref;
8978 }
8979
8980 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8981 CHECK(owner->result_ok);
8982         return ClosingSigned_clone(&*owner->contents.result);
8983 }
8984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8985         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8986         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
8987         int64_t ret_ref = 0;
8988         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8989         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8991         ret_ref = (uintptr_t)ret_var.inner;
8992         if (ret_var.is_owned) {
8993                 ret_ref |= 1;
8994         }
8995         return ret_ref;
8996 }
8997
8998 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8999 CHECK(!owner->result_ok);
9000         return DecodeError_clone(&*owner->contents.err);
9001 }
9002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9003         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
9004         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
9005         int64_t ret_ref = 0;
9006         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9007         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9009         ret_ref = (uintptr_t)ret_var.inner;
9010         if (ret_var.is_owned) {
9011                 ret_ref |= 1;
9012         }
9013         return ret_ref;
9014 }
9015
9016 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
9017 CHECK(owner->result_ok);
9018         return ClosingSignedFeeRange_clone(&*owner->contents.result);
9019 }
9020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9021         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
9022         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
9023         int64_t ret_ref = 0;
9024         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9025         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9026         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9027         ret_ref = (uintptr_t)ret_var.inner;
9028         if (ret_var.is_owned) {
9029                 ret_ref |= 1;
9030         }
9031         return ret_ref;
9032 }
9033
9034 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
9035 CHECK(!owner->result_ok);
9036         return DecodeError_clone(&*owner->contents.err);
9037 }
9038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9039         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
9040         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
9041         int64_t ret_ref = 0;
9042         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9043         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9045         ret_ref = (uintptr_t)ret_var.inner;
9046         if (ret_var.is_owned) {
9047                 ret_ref |= 1;
9048         }
9049         return ret_ref;
9050 }
9051
9052 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
9053 CHECK(owner->result_ok);
9054         return CommitmentSigned_clone(&*owner->contents.result);
9055 }
9056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9057         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
9058         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
9059         int64_t ret_ref = 0;
9060         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9061         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9062         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9063         ret_ref = (uintptr_t)ret_var.inner;
9064         if (ret_var.is_owned) {
9065                 ret_ref |= 1;
9066         }
9067         return ret_ref;
9068 }
9069
9070 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
9071 CHECK(!owner->result_ok);
9072         return DecodeError_clone(&*owner->contents.err);
9073 }
9074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9075         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
9076         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
9077         int64_t ret_ref = 0;
9078         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9079         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9081         ret_ref = (uintptr_t)ret_var.inner;
9082         if (ret_var.is_owned) {
9083                 ret_ref |= 1;
9084         }
9085         return ret_ref;
9086 }
9087
9088 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
9089 CHECK(owner->result_ok);
9090         return FundingCreated_clone(&*owner->contents.result);
9091 }
9092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9093         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
9094         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
9095         int64_t ret_ref = 0;
9096         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9097         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9099         ret_ref = (uintptr_t)ret_var.inner;
9100         if (ret_var.is_owned) {
9101                 ret_ref |= 1;
9102         }
9103         return ret_ref;
9104 }
9105
9106 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
9107 CHECK(!owner->result_ok);
9108         return DecodeError_clone(&*owner->contents.err);
9109 }
9110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9111         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
9112         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
9113         int64_t ret_ref = 0;
9114         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9115         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9117         ret_ref = (uintptr_t)ret_var.inner;
9118         if (ret_var.is_owned) {
9119                 ret_ref |= 1;
9120         }
9121         return ret_ref;
9122 }
9123
9124 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
9125 CHECK(owner->result_ok);
9126         return FundingSigned_clone(&*owner->contents.result);
9127 }
9128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9129         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
9130         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
9131         int64_t ret_ref = 0;
9132         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9133         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9135         ret_ref = (uintptr_t)ret_var.inner;
9136         if (ret_var.is_owned) {
9137                 ret_ref |= 1;
9138         }
9139         return ret_ref;
9140 }
9141
9142 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
9143 CHECK(!owner->result_ok);
9144         return DecodeError_clone(&*owner->contents.err);
9145 }
9146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9147         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
9148         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
9149         int64_t ret_ref = 0;
9150         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9151         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9153         ret_ref = (uintptr_t)ret_var.inner;
9154         if (ret_var.is_owned) {
9155                 ret_ref |= 1;
9156         }
9157         return ret_ref;
9158 }
9159
9160 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
9161 CHECK(owner->result_ok);
9162         return ChannelReady_clone(&*owner->contents.result);
9163 }
9164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9165         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
9166         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
9167         int64_t ret_ref = 0;
9168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9171         ret_ref = (uintptr_t)ret_var.inner;
9172         if (ret_var.is_owned) {
9173                 ret_ref |= 1;
9174         }
9175         return ret_ref;
9176 }
9177
9178 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
9179 CHECK(!owner->result_ok);
9180         return DecodeError_clone(&*owner->contents.err);
9181 }
9182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9183         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
9184         LDKDecodeError ret_var = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
9185         int64_t ret_ref = 0;
9186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9189         ret_ref = (uintptr_t)ret_var.inner;
9190         if (ret_var.is_owned) {
9191                 ret_ref |= 1;
9192         }
9193         return ret_ref;
9194 }
9195
9196 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
9197 CHECK(owner->result_ok);
9198         return Init_clone(&*owner->contents.result);
9199 }
9200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9201         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
9202         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
9203         int64_t ret_ref = 0;
9204         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9205         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9207         ret_ref = (uintptr_t)ret_var.inner;
9208         if (ret_var.is_owned) {
9209                 ret_ref |= 1;
9210         }
9211         return ret_ref;
9212 }
9213
9214 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
9215 CHECK(!owner->result_ok);
9216         return DecodeError_clone(&*owner->contents.err);
9217 }
9218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9219         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
9220         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
9221         int64_t ret_ref = 0;
9222         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9223         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9225         ret_ref = (uintptr_t)ret_var.inner;
9226         if (ret_var.is_owned) {
9227                 ret_ref |= 1;
9228         }
9229         return ret_ref;
9230 }
9231
9232 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9233 CHECK(owner->result_ok);
9234         return OpenChannel_clone(&*owner->contents.result);
9235 }
9236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9237         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
9238         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
9239         int64_t ret_ref = 0;
9240         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9241         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9243         ret_ref = (uintptr_t)ret_var.inner;
9244         if (ret_var.is_owned) {
9245                 ret_ref |= 1;
9246         }
9247         return ret_ref;
9248 }
9249
9250 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9251 CHECK(!owner->result_ok);
9252         return DecodeError_clone(&*owner->contents.err);
9253 }
9254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9255         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
9256         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
9257         int64_t ret_ref = 0;
9258         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9259         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9261         ret_ref = (uintptr_t)ret_var.inner;
9262         if (ret_var.is_owned) {
9263                 ret_ref |= 1;
9264         }
9265         return ret_ref;
9266 }
9267
9268 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9269 CHECK(owner->result_ok);
9270         return RevokeAndACK_clone(&*owner->contents.result);
9271 }
9272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9273         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
9274         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
9275         int64_t ret_ref = 0;
9276         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9277         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9279         ret_ref = (uintptr_t)ret_var.inner;
9280         if (ret_var.is_owned) {
9281                 ret_ref |= 1;
9282         }
9283         return ret_ref;
9284 }
9285
9286 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9287 CHECK(!owner->result_ok);
9288         return DecodeError_clone(&*owner->contents.err);
9289 }
9290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9291         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
9292         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
9293         int64_t ret_ref = 0;
9294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9297         ret_ref = (uintptr_t)ret_var.inner;
9298         if (ret_var.is_owned) {
9299                 ret_ref |= 1;
9300         }
9301         return ret_ref;
9302 }
9303
9304 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9305 CHECK(owner->result_ok);
9306         return Shutdown_clone(&*owner->contents.result);
9307 }
9308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9309         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
9310         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
9311         int64_t ret_ref = 0;
9312         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9313         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9315         ret_ref = (uintptr_t)ret_var.inner;
9316         if (ret_var.is_owned) {
9317                 ret_ref |= 1;
9318         }
9319         return ret_ref;
9320 }
9321
9322 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9323 CHECK(!owner->result_ok);
9324         return DecodeError_clone(&*owner->contents.err);
9325 }
9326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9327         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
9328         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
9329         int64_t ret_ref = 0;
9330         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9331         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9333         ret_ref = (uintptr_t)ret_var.inner;
9334         if (ret_var.is_owned) {
9335                 ret_ref |= 1;
9336         }
9337         return ret_ref;
9338 }
9339
9340 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
9341 CHECK(owner->result_ok);
9342         return UpdateFailHTLC_clone(&*owner->contents.result);
9343 }
9344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9345         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
9346         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
9347         int64_t ret_ref = 0;
9348         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9349         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9351         ret_ref = (uintptr_t)ret_var.inner;
9352         if (ret_var.is_owned) {
9353                 ret_ref |= 1;
9354         }
9355         return ret_ref;
9356 }
9357
9358 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
9359 CHECK(!owner->result_ok);
9360         return DecodeError_clone(&*owner->contents.err);
9361 }
9362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9363         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
9364         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
9365         int64_t ret_ref = 0;
9366         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9367         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9369         ret_ref = (uintptr_t)ret_var.inner;
9370         if (ret_var.is_owned) {
9371                 ret_ref |= 1;
9372         }
9373         return ret_ref;
9374 }
9375
9376 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9377 CHECK(owner->result_ok);
9378         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
9379 }
9380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9381         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
9382         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
9383         int64_t ret_ref = 0;
9384         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9385         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9387         ret_ref = (uintptr_t)ret_var.inner;
9388         if (ret_var.is_owned) {
9389                 ret_ref |= 1;
9390         }
9391         return ret_ref;
9392 }
9393
9394 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9395 CHECK(!owner->result_ok);
9396         return DecodeError_clone(&*owner->contents.err);
9397 }
9398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9399         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
9400         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
9401         int64_t ret_ref = 0;
9402         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9403         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9405         ret_ref = (uintptr_t)ret_var.inner;
9406         if (ret_var.is_owned) {
9407                 ret_ref |= 1;
9408         }
9409         return ret_ref;
9410 }
9411
9412 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9413 CHECK(owner->result_ok);
9414         return UpdateFee_clone(&*owner->contents.result);
9415 }
9416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9417         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
9418         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
9419         int64_t ret_ref = 0;
9420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9423         ret_ref = (uintptr_t)ret_var.inner;
9424         if (ret_var.is_owned) {
9425                 ret_ref |= 1;
9426         }
9427         return ret_ref;
9428 }
9429
9430 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9431 CHECK(!owner->result_ok);
9432         return DecodeError_clone(&*owner->contents.err);
9433 }
9434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9435         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
9436         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
9437         int64_t ret_ref = 0;
9438         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9439         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9441         ret_ref = (uintptr_t)ret_var.inner;
9442         if (ret_var.is_owned) {
9443                 ret_ref |= 1;
9444         }
9445         return ret_ref;
9446 }
9447
9448 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9449 CHECK(owner->result_ok);
9450         return UpdateFulfillHTLC_clone(&*owner->contents.result);
9451 }
9452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9453         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
9454         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
9455         int64_t ret_ref = 0;
9456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9459         ret_ref = (uintptr_t)ret_var.inner;
9460         if (ret_var.is_owned) {
9461                 ret_ref |= 1;
9462         }
9463         return ret_ref;
9464 }
9465
9466 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9467 CHECK(!owner->result_ok);
9468         return DecodeError_clone(&*owner->contents.err);
9469 }
9470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9471         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
9472         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
9473         int64_t ret_ref = 0;
9474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9477         ret_ref = (uintptr_t)ret_var.inner;
9478         if (ret_var.is_owned) {
9479                 ret_ref |= 1;
9480         }
9481         return ret_ref;
9482 }
9483
9484 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9485 CHECK(owner->result_ok);
9486         return UpdateAddHTLC_clone(&*owner->contents.result);
9487 }
9488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9489         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
9490         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
9491         int64_t ret_ref = 0;
9492         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9493         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9495         ret_ref = (uintptr_t)ret_var.inner;
9496         if (ret_var.is_owned) {
9497                 ret_ref |= 1;
9498         }
9499         return ret_ref;
9500 }
9501
9502 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9503 CHECK(!owner->result_ok);
9504         return DecodeError_clone(&*owner->contents.err);
9505 }
9506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9507         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
9508         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
9509         int64_t ret_ref = 0;
9510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9513         ret_ref = (uintptr_t)ret_var.inner;
9514         if (ret_var.is_owned) {
9515                 ret_ref |= 1;
9516         }
9517         return ret_ref;
9518 }
9519
9520 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9521 CHECK(owner->result_ok);
9522         return Ping_clone(&*owner->contents.result);
9523 }
9524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9525         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
9526         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
9527         int64_t ret_ref = 0;
9528         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9529         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9531         ret_ref = (uintptr_t)ret_var.inner;
9532         if (ret_var.is_owned) {
9533                 ret_ref |= 1;
9534         }
9535         return ret_ref;
9536 }
9537
9538 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9539 CHECK(!owner->result_ok);
9540         return DecodeError_clone(&*owner->contents.err);
9541 }
9542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9543         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
9544         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
9545         int64_t ret_ref = 0;
9546         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9547         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9548         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9549         ret_ref = (uintptr_t)ret_var.inner;
9550         if (ret_var.is_owned) {
9551                 ret_ref |= 1;
9552         }
9553         return ret_ref;
9554 }
9555
9556 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9557 CHECK(owner->result_ok);
9558         return Pong_clone(&*owner->contents.result);
9559 }
9560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9561         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
9562         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
9563         int64_t ret_ref = 0;
9564         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9565         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9567         ret_ref = (uintptr_t)ret_var.inner;
9568         if (ret_var.is_owned) {
9569                 ret_ref |= 1;
9570         }
9571         return ret_ref;
9572 }
9573
9574 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9575 CHECK(!owner->result_ok);
9576         return DecodeError_clone(&*owner->contents.err);
9577 }
9578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9579         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
9580         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
9581         int64_t ret_ref = 0;
9582         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9583         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9585         ret_ref = (uintptr_t)ret_var.inner;
9586         if (ret_var.is_owned) {
9587                 ret_ref |= 1;
9588         }
9589         return ret_ref;
9590 }
9591
9592 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9593 CHECK(owner->result_ok);
9594         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
9595 }
9596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9597         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9598         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9599         int64_t ret_ref = 0;
9600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9603         ret_ref = (uintptr_t)ret_var.inner;
9604         if (ret_var.is_owned) {
9605                 ret_ref |= 1;
9606         }
9607         return ret_ref;
9608 }
9609
9610 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9611 CHECK(!owner->result_ok);
9612         return DecodeError_clone(&*owner->contents.err);
9613 }
9614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9615         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9616         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9617         int64_t ret_ref = 0;
9618         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9619         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9621         ret_ref = (uintptr_t)ret_var.inner;
9622         if (ret_var.is_owned) {
9623                 ret_ref |= 1;
9624         }
9625         return ret_ref;
9626 }
9627
9628 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9629 CHECK(owner->result_ok);
9630         return ChannelAnnouncement_clone(&*owner->contents.result);
9631 }
9632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9633         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9634         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9635         int64_t ret_ref = 0;
9636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9639         ret_ref = (uintptr_t)ret_var.inner;
9640         if (ret_var.is_owned) {
9641                 ret_ref |= 1;
9642         }
9643         return ret_ref;
9644 }
9645
9646 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9647 CHECK(!owner->result_ok);
9648         return DecodeError_clone(&*owner->contents.err);
9649 }
9650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9651         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9652         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9653         int64_t ret_ref = 0;
9654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9657         ret_ref = (uintptr_t)ret_var.inner;
9658         if (ret_var.is_owned) {
9659                 ret_ref |= 1;
9660         }
9661         return ret_ref;
9662 }
9663
9664 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9665 CHECK(owner->result_ok);
9666         return UnsignedChannelUpdate_clone(&*owner->contents.result);
9667 }
9668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9669         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
9670         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9671         int64_t ret_ref = 0;
9672         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9673         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9675         ret_ref = (uintptr_t)ret_var.inner;
9676         if (ret_var.is_owned) {
9677                 ret_ref |= 1;
9678         }
9679         return ret_ref;
9680 }
9681
9682 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9683 CHECK(!owner->result_ok);
9684         return DecodeError_clone(&*owner->contents.err);
9685 }
9686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9687         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
9688         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
9689         int64_t ret_ref = 0;
9690         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9691         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9693         ret_ref = (uintptr_t)ret_var.inner;
9694         if (ret_var.is_owned) {
9695                 ret_ref |= 1;
9696         }
9697         return ret_ref;
9698 }
9699
9700 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9701 CHECK(owner->result_ok);
9702         return ChannelUpdate_clone(&*owner->contents.result);
9703 }
9704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9705         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
9706         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9707         int64_t ret_ref = 0;
9708         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9709         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9711         ret_ref = (uintptr_t)ret_var.inner;
9712         if (ret_var.is_owned) {
9713                 ret_ref |= 1;
9714         }
9715         return ret_ref;
9716 }
9717
9718 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9719 CHECK(!owner->result_ok);
9720         return DecodeError_clone(&*owner->contents.err);
9721 }
9722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9723         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
9724         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
9725         int64_t ret_ref = 0;
9726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9729         ret_ref = (uintptr_t)ret_var.inner;
9730         if (ret_var.is_owned) {
9731                 ret_ref |= 1;
9732         }
9733         return ret_ref;
9734 }
9735
9736 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9737 CHECK(owner->result_ok);
9738         return ErrorMessage_clone(&*owner->contents.result);
9739 }
9740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9741         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9742         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
9743         int64_t ret_ref = 0;
9744         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9745         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9747         ret_ref = (uintptr_t)ret_var.inner;
9748         if (ret_var.is_owned) {
9749                 ret_ref |= 1;
9750         }
9751         return ret_ref;
9752 }
9753
9754 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9755 CHECK(!owner->result_ok);
9756         return DecodeError_clone(&*owner->contents.err);
9757 }
9758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9759         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9760         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
9761         int64_t ret_ref = 0;
9762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9765         ret_ref = (uintptr_t)ret_var.inner;
9766         if (ret_var.is_owned) {
9767                 ret_ref |= 1;
9768         }
9769         return ret_ref;
9770 }
9771
9772 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9773 CHECK(owner->result_ok);
9774         return WarningMessage_clone(&*owner->contents.result);
9775 }
9776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9777         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9778         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
9779         int64_t ret_ref = 0;
9780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9783         ret_ref = (uintptr_t)ret_var.inner;
9784         if (ret_var.is_owned) {
9785                 ret_ref |= 1;
9786         }
9787         return ret_ref;
9788 }
9789
9790 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9791 CHECK(!owner->result_ok);
9792         return DecodeError_clone(&*owner->contents.err);
9793 }
9794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9795         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9796         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
9797         int64_t ret_ref = 0;
9798         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9799         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9801         ret_ref = (uintptr_t)ret_var.inner;
9802         if (ret_var.is_owned) {
9803                 ret_ref |= 1;
9804         }
9805         return ret_ref;
9806 }
9807
9808 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9809 CHECK(owner->result_ok);
9810         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
9811 }
9812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9813         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9814         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9815         int64_t ret_ref = 0;
9816         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9817         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9819         ret_ref = (uintptr_t)ret_var.inner;
9820         if (ret_var.is_owned) {
9821                 ret_ref |= 1;
9822         }
9823         return ret_ref;
9824 }
9825
9826 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9827 CHECK(!owner->result_ok);
9828         return DecodeError_clone(&*owner->contents.err);
9829 }
9830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9831         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9832         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9833         int64_t ret_ref = 0;
9834         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9835         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9837         ret_ref = (uintptr_t)ret_var.inner;
9838         if (ret_var.is_owned) {
9839                 ret_ref |= 1;
9840         }
9841         return ret_ref;
9842 }
9843
9844 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9845 CHECK(owner->result_ok);
9846         return NodeAnnouncement_clone(&*owner->contents.result);
9847 }
9848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9849         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9850         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9851         int64_t ret_ref = 0;
9852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9855         ret_ref = (uintptr_t)ret_var.inner;
9856         if (ret_var.is_owned) {
9857                 ret_ref |= 1;
9858         }
9859         return ret_ref;
9860 }
9861
9862 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9863 CHECK(!owner->result_ok);
9864         return DecodeError_clone(&*owner->contents.err);
9865 }
9866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9867         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9868         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9869         int64_t ret_ref = 0;
9870         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9871         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9873         ret_ref = (uintptr_t)ret_var.inner;
9874         if (ret_var.is_owned) {
9875                 ret_ref |= 1;
9876         }
9877         return ret_ref;
9878 }
9879
9880 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9881 CHECK(owner->result_ok);
9882         return QueryShortChannelIds_clone(&*owner->contents.result);
9883 }
9884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9885         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9886         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
9887         int64_t ret_ref = 0;
9888         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9889         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9891         ret_ref = (uintptr_t)ret_var.inner;
9892         if (ret_var.is_owned) {
9893                 ret_ref |= 1;
9894         }
9895         return ret_ref;
9896 }
9897
9898 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9899 CHECK(!owner->result_ok);
9900         return DecodeError_clone(&*owner->contents.err);
9901 }
9902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9903         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9904         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
9905         int64_t ret_ref = 0;
9906         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9907         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9909         ret_ref = (uintptr_t)ret_var.inner;
9910         if (ret_var.is_owned) {
9911                 ret_ref |= 1;
9912         }
9913         return ret_ref;
9914 }
9915
9916 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9917 CHECK(owner->result_ok);
9918         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
9919 }
9920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9921         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9922         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
9923         int64_t ret_ref = 0;
9924         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9925         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9927         ret_ref = (uintptr_t)ret_var.inner;
9928         if (ret_var.is_owned) {
9929                 ret_ref |= 1;
9930         }
9931         return ret_ref;
9932 }
9933
9934 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9935 CHECK(!owner->result_ok);
9936         return DecodeError_clone(&*owner->contents.err);
9937 }
9938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9939         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9940         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
9941         int64_t ret_ref = 0;
9942         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9943         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9945         ret_ref = (uintptr_t)ret_var.inner;
9946         if (ret_var.is_owned) {
9947                 ret_ref |= 1;
9948         }
9949         return ret_ref;
9950 }
9951
9952 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9953 CHECK(owner->result_ok);
9954         return QueryChannelRange_clone(&*owner->contents.result);
9955 }
9956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9957         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9958         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
9959         int64_t ret_ref = 0;
9960         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9961         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9963         ret_ref = (uintptr_t)ret_var.inner;
9964         if (ret_var.is_owned) {
9965                 ret_ref |= 1;
9966         }
9967         return ret_ref;
9968 }
9969
9970 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9971 CHECK(!owner->result_ok);
9972         return DecodeError_clone(&*owner->contents.err);
9973 }
9974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9975         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9976         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
9977         int64_t ret_ref = 0;
9978         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9979         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9981         ret_ref = (uintptr_t)ret_var.inner;
9982         if (ret_var.is_owned) {
9983                 ret_ref |= 1;
9984         }
9985         return ret_ref;
9986 }
9987
9988 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9989 CHECK(owner->result_ok);
9990         return ReplyChannelRange_clone(&*owner->contents.result);
9991 }
9992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9993         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9994         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
9995         int64_t ret_ref = 0;
9996         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9997         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9999         ret_ref = (uintptr_t)ret_var.inner;
10000         if (ret_var.is_owned) {
10001                 ret_ref |= 1;
10002         }
10003         return ret_ref;
10004 }
10005
10006 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10007 CHECK(!owner->result_ok);
10008         return DecodeError_clone(&*owner->contents.err);
10009 }
10010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10011         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
10012         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
10013         int64_t ret_ref = 0;
10014         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10015         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10017         ret_ref = (uintptr_t)ret_var.inner;
10018         if (ret_var.is_owned) {
10019                 ret_ref |= 1;
10020         }
10021         return ret_ref;
10022 }
10023
10024 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
10025 CHECK(owner->result_ok);
10026         return GossipTimestampFilter_clone(&*owner->contents.result);
10027 }
10028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10029         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
10030         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
10031         int64_t ret_ref = 0;
10032         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10033         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10035         ret_ref = (uintptr_t)ret_var.inner;
10036         if (ret_var.is_owned) {
10037                 ret_ref |= 1;
10038         }
10039         return ret_ref;
10040 }
10041
10042 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
10043 CHECK(!owner->result_ok);
10044         return DecodeError_clone(&*owner->contents.err);
10045 }
10046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10047         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
10048         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
10049         int64_t ret_ref = 0;
10050         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10051         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10053         ret_ref = (uintptr_t)ret_var.inner;
10054         if (ret_var.is_owned) {
10055                 ret_ref |= 1;
10056         }
10057         return ret_ref;
10058 }
10059
10060 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
10061         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
10062         for (size_t i = 0; i < ret.datalen; i++) {
10063                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
10064         }
10065         return ret;
10066 }
10067 static jclass LDKSignOrCreationError_SignError_class = NULL;
10068 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
10069 static jclass LDKSignOrCreationError_CreationError_class = NULL;
10070 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
10071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
10072         LDKSignOrCreationError_SignError_class =
10073                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
10074         CHECK(LDKSignOrCreationError_SignError_class != NULL);
10075         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
10076         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
10077         LDKSignOrCreationError_CreationError_class =
10078                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
10079         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
10080         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
10081         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
10082 }
10083 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10084         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
10085         switch(obj->tag) {
10086                 case LDKSignOrCreationError_SignError: {
10087                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
10088                 }
10089                 case LDKSignOrCreationError_CreationError: {
10090                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
10091                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
10092                 }
10093                 default: abort();
10094         }
10095 }
10096 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
10097 CHECK(owner->result_ok);
10098         return Invoice_clone(&*owner->contents.result);
10099 }
10100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10101         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
10102         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
10103         int64_t ret_ref = 0;
10104         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10105         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10107         ret_ref = (uintptr_t)ret_var.inner;
10108         if (ret_var.is_owned) {
10109                 ret_ref |= 1;
10110         }
10111         return ret_ref;
10112 }
10113
10114 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
10115 CHECK(!owner->result_ok);
10116         return SignOrCreationError_clone(&*owner->contents.err);
10117 }
10118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10119         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
10120         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
10121         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
10122         int64_t ret_ref = (uintptr_t)ret_copy;
10123         return ret_ref;
10124 }
10125
10126 typedef struct LDKFilter_JCalls {
10127         atomic_size_t refcnt;
10128         JavaVM *vm;
10129         jweak o;
10130         jmethodID register_tx_meth;
10131         jmethodID register_output_meth;
10132 } LDKFilter_JCalls;
10133 static void LDKFilter_JCalls_free(void* this_arg) {
10134         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10135         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10136                 JNIEnv *env;
10137                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10138                 if (get_jenv_res == JNI_EDETACHED) {
10139                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10140                 } else {
10141                         DO_ASSERT(get_jenv_res == JNI_OK);
10142                 }
10143                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10144                 if (get_jenv_res == JNI_EDETACHED) {
10145                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10146                 }
10147                 FREE(j_calls);
10148         }
10149 }
10150 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
10151         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10152         JNIEnv *env;
10153         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10154         if (get_jenv_res == JNI_EDETACHED) {
10155                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10156         } else {
10157                 DO_ASSERT(get_jenv_res == JNI_OK);
10158         }
10159         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
10160         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
10161         LDKu8slice script_pubkey_var = script_pubkey;
10162         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
10163         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
10164         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10165         CHECK(obj != NULL);
10166         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
10167         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10168                 (*env)->ExceptionDescribe(env);
10169                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
10170         }
10171         if (get_jenv_res == JNI_EDETACHED) {
10172                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10173         }
10174 }
10175 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
10176         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10177         JNIEnv *env;
10178         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10179         if (get_jenv_res == JNI_EDETACHED) {
10180                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10181         } else {
10182                 DO_ASSERT(get_jenv_res == JNI_OK);
10183         }
10184         LDKWatchedOutput output_var = output;
10185         int64_t output_ref = 0;
10186         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10187         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10188         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
10189         output_ref = (uintptr_t)output_var.inner;
10190         if (output_var.is_owned) {
10191                 output_ref |= 1;
10192         }
10193         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10194         CHECK(obj != NULL);
10195         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
10196         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10197                 (*env)->ExceptionDescribe(env);
10198                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
10199         }
10200         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10201         CHECK_ACCESS(ret_ptr);
10202         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
10203         FREE((void*)ret);
10204         if (get_jenv_res == JNI_EDETACHED) {
10205                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10206         }
10207         return ret_conv;
10208 }
10209 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
10210         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
10211         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10212 }
10213 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
10214         jclass c = (*env)->GetObjectClass(env, o);
10215         CHECK(c != NULL);
10216         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
10217         atomic_init(&calls->refcnt, 1);
10218         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10219         calls->o = (*env)->NewWeakGlobalRef(env, o);
10220         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
10221         CHECK(calls->register_tx_meth != NULL);
10222         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
10223         CHECK(calls->register_output_meth != NULL);
10224
10225         LDKFilter ret = {
10226                 .this_arg = (void*) calls,
10227                 .register_tx = register_tx_LDKFilter_jcall,
10228                 .register_output = register_output_LDKFilter_jcall,
10229                 .free = LDKFilter_JCalls_free,
10230         };
10231         return ret;
10232 }
10233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
10234         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
10235         *res_ptr = LDKFilter_init(env, clz, o);
10236         return (uint64_t)res_ptr;
10237 }
10238 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) {
10239         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10240         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10241         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10242         unsigned char txid_arr[32];
10243         CHECK((*env)->GetArrayLength(env, txid) == 32);
10244         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
10245         unsigned char (*txid_ref)[32] = &txid_arr;
10246         LDKu8slice script_pubkey_ref;
10247         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
10248         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
10249         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
10250         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
10251 }
10252
10253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
10254         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10255         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10256         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10257         LDKWatchedOutput output_conv;
10258         output_conv.inner = (void*)(output & (~1));
10259         output_conv.is_owned = (output & 1) || (output == 0);
10260         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
10261         output_conv = WatchedOutput_clone(&output_conv);
10262         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
10263         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
10264         int64_t ret_ref = (uintptr_t)ret_copy;
10265         return ret_ref;
10266 }
10267
10268 static jclass LDKCOption_FilterZ_Some_class = NULL;
10269 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
10270 static jclass LDKCOption_FilterZ_None_class = NULL;
10271 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
10272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
10273         LDKCOption_FilterZ_Some_class =
10274                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
10275         CHECK(LDKCOption_FilterZ_Some_class != NULL);
10276         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
10277         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
10278         LDKCOption_FilterZ_None_class =
10279                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
10280         CHECK(LDKCOption_FilterZ_None_class != NULL);
10281         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
10282         CHECK(LDKCOption_FilterZ_None_meth != NULL);
10283 }
10284 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10285         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
10286         switch(obj->tag) {
10287                 case LDKCOption_FilterZ_Some: {
10288                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
10289                         *some_ret = obj->some;
10290                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
10291                         if ((*some_ret).free == LDKFilter_JCalls_free) {
10292                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10293                                 LDKFilter_JCalls_cloned(&(*some_ret));
10294                         }
10295                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (int64_t)some_ret);
10296                 }
10297                 case LDKCOption_FilterZ_None: {
10298                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
10299                 }
10300                 default: abort();
10301         }
10302 }
10303 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10304 CHECK(owner->result_ok);
10305         return &*owner->contents.result;
10306 }
10307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10308         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
10309         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
10310         int64_t ret_ref = 0;
10311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10314         ret_ref = (uintptr_t)ret_var.inner & ~1;
10315         return ret_ref;
10316 }
10317
10318 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10319 CHECK(!owner->result_ok);
10320         return *owner->contents.err;
10321 }
10322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10323         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
10324         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
10325 }
10326
10327 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
10328         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
10329         for (size_t i = 0; i < ret.datalen; i++) {
10330                 ret.data[i] = OutPoint_clone(&orig->data[i]);
10331         }
10332         return ret;
10333 }
10334 typedef struct LDKMessageSendEventsProvider_JCalls {
10335         atomic_size_t refcnt;
10336         JavaVM *vm;
10337         jweak o;
10338         jmethodID get_and_clear_pending_msg_events_meth;
10339 } LDKMessageSendEventsProvider_JCalls;
10340 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
10341         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10342         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10343                 JNIEnv *env;
10344                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10345                 if (get_jenv_res == JNI_EDETACHED) {
10346                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10347                 } else {
10348                         DO_ASSERT(get_jenv_res == JNI_OK);
10349                 }
10350                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10351                 if (get_jenv_res == JNI_EDETACHED) {
10352                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10353                 }
10354                 FREE(j_calls);
10355         }
10356 }
10357 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
10358         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10359         JNIEnv *env;
10360         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10361         if (get_jenv_res == JNI_EDETACHED) {
10362                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10363         } else {
10364                 DO_ASSERT(get_jenv_res == JNI_OK);
10365         }
10366         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10367         CHECK(obj != NULL);
10368         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
10369         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10370                 (*env)->ExceptionDescribe(env);
10371                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
10372         }
10373         LDKCVec_MessageSendEventZ ret_constr;
10374         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10375         if (ret_constr.datalen > 0)
10376                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
10377         else
10378                 ret_constr.data = NULL;
10379         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
10380         for (size_t s = 0; s < ret_constr.datalen; s++) {
10381                 int64_t ret_conv_18 = ret_vals[s];
10382                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
10383                 CHECK_ACCESS(ret_conv_18_ptr);
10384                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
10385                 FREE((void*)ret_conv_18);
10386                 ret_constr.data[s] = ret_conv_18_conv;
10387         }
10388         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
10389         if (get_jenv_res == JNI_EDETACHED) {
10390                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10391         }
10392         return ret_constr;
10393 }
10394 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
10395         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
10396         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10397 }
10398 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10399         jclass c = (*env)->GetObjectClass(env, o);
10400         CHECK(c != NULL);
10401         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
10402         atomic_init(&calls->refcnt, 1);
10403         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10404         calls->o = (*env)->NewWeakGlobalRef(env, o);
10405         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
10406         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
10407
10408         LDKMessageSendEventsProvider ret = {
10409                 .this_arg = (void*) calls,
10410                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
10411                 .free = LDKMessageSendEventsProvider_JCalls_free,
10412         };
10413         return ret;
10414 }
10415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10416         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
10417         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
10418         return (uint64_t)res_ptr;
10419 }
10420 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10421         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10422         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10423         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
10424         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
10425         int64_tArray ret_arr = NULL;
10426         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10427         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10428         for (size_t s = 0; s < ret_var.datalen; s++) {
10429                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10430                 *ret_conv_18_copy = ret_var.data[s];
10431                 int64_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
10432                 ret_arr_ptr[s] = ret_conv_18_ref;
10433         }
10434         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10435         FREE(ret_var.data);
10436         return ret_arr;
10437 }
10438
10439 typedef struct LDKEventHandler_JCalls {
10440         atomic_size_t refcnt;
10441         JavaVM *vm;
10442         jweak o;
10443         jmethodID handle_event_meth;
10444 } LDKEventHandler_JCalls;
10445 static void LDKEventHandler_JCalls_free(void* this_arg) {
10446         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10447         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10448                 JNIEnv *env;
10449                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10450                 if (get_jenv_res == JNI_EDETACHED) {
10451                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10452                 } else {
10453                         DO_ASSERT(get_jenv_res == JNI_OK);
10454                 }
10455                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10456                 if (get_jenv_res == JNI_EDETACHED) {
10457                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10458                 }
10459                 FREE(j_calls);
10460         }
10461 }
10462 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
10463         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10464         JNIEnv *env;
10465         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10466         if (get_jenv_res == JNI_EDETACHED) {
10467                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10468         } else {
10469                 DO_ASSERT(get_jenv_res == JNI_OK);
10470         }
10471         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
10472         *ret_event = Event_clone(event);
10473         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10474         CHECK(obj != NULL);
10475         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (int64_t)ret_event);
10476         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10477                 (*env)->ExceptionDescribe(env);
10478                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
10479         }
10480         if (get_jenv_res == JNI_EDETACHED) {
10481                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10482         }
10483 }
10484 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
10485         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
10486         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10487 }
10488 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
10489         jclass c = (*env)->GetObjectClass(env, o);
10490         CHECK(c != NULL);
10491         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
10492         atomic_init(&calls->refcnt, 1);
10493         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10494         calls->o = (*env)->NewWeakGlobalRef(env, o);
10495         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
10496         CHECK(calls->handle_event_meth != NULL);
10497
10498         LDKEventHandler ret = {
10499                 .this_arg = (void*) calls,
10500                 .handle_event = handle_event_LDKEventHandler_jcall,
10501                 .free = LDKEventHandler_JCalls_free,
10502         };
10503         return ret;
10504 }
10505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
10506         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10507         *res_ptr = LDKEventHandler_init(env, clz, o);
10508         return (uint64_t)res_ptr;
10509 }
10510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
10511         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10512         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10513         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
10514         LDKEvent* event_conv = (LDKEvent*)event;
10515         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
10516 }
10517
10518 typedef struct LDKEventsProvider_JCalls {
10519         atomic_size_t refcnt;
10520         JavaVM *vm;
10521         jweak o;
10522         jmethodID process_pending_events_meth;
10523 } LDKEventsProvider_JCalls;
10524 static void LDKEventsProvider_JCalls_free(void* this_arg) {
10525         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10526         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10527                 JNIEnv *env;
10528                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10529                 if (get_jenv_res == JNI_EDETACHED) {
10530                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10531                 } else {
10532                         DO_ASSERT(get_jenv_res == JNI_OK);
10533                 }
10534                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10535                 if (get_jenv_res == JNI_EDETACHED) {
10536                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10537                 }
10538                 FREE(j_calls);
10539         }
10540 }
10541 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
10542         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10543         JNIEnv *env;
10544         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10545         if (get_jenv_res == JNI_EDETACHED) {
10546                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10547         } else {
10548                 DO_ASSERT(get_jenv_res == JNI_OK);
10549         }
10550         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10551         *handler_ret = handler;
10552         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10553         CHECK(obj != NULL);
10554         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (int64_t)handler_ret);
10555         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10556                 (*env)->ExceptionDescribe(env);
10557                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
10558         }
10559         if (get_jenv_res == JNI_EDETACHED) {
10560                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10561         }
10562 }
10563 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
10564         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
10565         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10566 }
10567 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10568         jclass c = (*env)->GetObjectClass(env, o);
10569         CHECK(c != NULL);
10570         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
10571         atomic_init(&calls->refcnt, 1);
10572         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10573         calls->o = (*env)->NewWeakGlobalRef(env, o);
10574         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
10575         CHECK(calls->process_pending_events_meth != NULL);
10576
10577         LDKEventsProvider ret = {
10578                 .this_arg = (void*) calls,
10579                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
10580                 .free = LDKEventsProvider_JCalls_free,
10581         };
10582         return ret;
10583 }
10584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10585         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
10586         *res_ptr = LDKEventsProvider_init(env, clz, o);
10587         return (uint64_t)res_ptr;
10588 }
10589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
10590         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10591         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10592         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
10593         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
10594         CHECK_ACCESS(handler_ptr);
10595         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
10596         if (handler_conv.free == LDKEventHandler_JCalls_free) {
10597                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10598                 LDKEventHandler_JCalls_cloned(&handler_conv);
10599         }
10600         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
10601 }
10602
10603 typedef struct LDKScore_JCalls {
10604         atomic_size_t refcnt;
10605         JavaVM *vm;
10606         jweak o;
10607         jmethodID channel_penalty_msat_meth;
10608         jmethodID payment_path_failed_meth;
10609         jmethodID payment_path_successful_meth;
10610         jmethodID probe_failed_meth;
10611         jmethodID probe_successful_meth;
10612         jmethodID write_meth;
10613 } LDKScore_JCalls;
10614 static void LDKScore_JCalls_free(void* this_arg) {
10615         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10616         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10617                 JNIEnv *env;
10618                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10619                 if (get_jenv_res == JNI_EDETACHED) {
10620                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10621                 } else {
10622                         DO_ASSERT(get_jenv_res == JNI_OK);
10623                 }
10624                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10625                 if (get_jenv_res == JNI_EDETACHED) {
10626                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10627                 }
10628                 FREE(j_calls);
10629         }
10630 }
10631 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
10632         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10633         JNIEnv *env;
10634         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10635         if (get_jenv_res == JNI_EDETACHED) {
10636                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10637         } else {
10638                 DO_ASSERT(get_jenv_res == JNI_OK);
10639         }
10640         int64_t short_channel_id_conv = short_channel_id;
10641         LDKNodeId source_var = *source;
10642         int64_t source_ref = 0;
10643         source_var = NodeId_clone(&source_var);
10644         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10645         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10646         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
10647         source_ref = (uintptr_t)source_var.inner;
10648         if (source_var.is_owned) {
10649                 source_ref |= 1;
10650         }
10651         LDKNodeId target_var = *target;
10652         int64_t target_ref = 0;
10653         target_var = NodeId_clone(&target_var);
10654         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10655         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10656         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
10657         target_ref = (uintptr_t)target_var.inner;
10658         if (target_var.is_owned) {
10659                 target_ref |= 1;
10660         }
10661         LDKChannelUsage usage_var = usage;
10662         int64_t usage_ref = 0;
10663         CHECK((((uintptr_t)usage_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10664         CHECK((((uintptr_t)&usage_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10665         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
10666         usage_ref = (uintptr_t)usage_var.inner;
10667         if (usage_var.is_owned) {
10668                 usage_ref |= 1;
10669         }
10670         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10671         CHECK(obj != NULL);
10672         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id_conv, source_ref, target_ref, usage_ref);
10673         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10674                 (*env)->ExceptionDescribe(env);
10675                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
10676         }
10677         if (get_jenv_res == JNI_EDETACHED) {
10678                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10679         }
10680         return ret;
10681 }
10682 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
10683         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10684         JNIEnv *env;
10685         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10686         if (get_jenv_res == JNI_EDETACHED) {
10687                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10688         } else {
10689                 DO_ASSERT(get_jenv_res == JNI_OK);
10690         }
10691         LDKCVec_RouteHopZ path_var = path;
10692         int64_tArray path_arr = NULL;
10693         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10694         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10695         for (size_t k = 0; k < path_var.datalen; k++) {
10696                 LDKRouteHop path_conv_10_var = path_var.data[k];
10697                 int64_t path_conv_10_ref = 0;
10698                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10699                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10700                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10701                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10702                 if (path_conv_10_var.is_owned) {
10703                         path_conv_10_ref |= 1;
10704                 }
10705                 path_arr_ptr[k] = path_conv_10_ref;
10706         }
10707         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10708         FREE(path_var.data);
10709         int64_t short_channel_id_conv = short_channel_id;
10710         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10711         CHECK(obj != NULL);
10712         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id_conv);
10713         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10714                 (*env)->ExceptionDescribe(env);
10715                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
10716         }
10717         if (get_jenv_res == JNI_EDETACHED) {
10718                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10719         }
10720 }
10721 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
10722         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10723         JNIEnv *env;
10724         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10725         if (get_jenv_res == JNI_EDETACHED) {
10726                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10727         } else {
10728                 DO_ASSERT(get_jenv_res == JNI_OK);
10729         }
10730         LDKCVec_RouteHopZ path_var = path;
10731         int64_tArray path_arr = NULL;
10732         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10733         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10734         for (size_t k = 0; k < path_var.datalen; k++) {
10735                 LDKRouteHop path_conv_10_var = path_var.data[k];
10736                 int64_t path_conv_10_ref = 0;
10737                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10738                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10739                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10740                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10741                 if (path_conv_10_var.is_owned) {
10742                         path_conv_10_ref |= 1;
10743                 }
10744                 path_arr_ptr[k] = path_conv_10_ref;
10745         }
10746         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10747         FREE(path_var.data);
10748         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10749         CHECK(obj != NULL);
10750         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
10751         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10752                 (*env)->ExceptionDescribe(env);
10753                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
10754         }
10755         if (get_jenv_res == JNI_EDETACHED) {
10756                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10757         }
10758 }
10759 void probe_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
10760         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10761         JNIEnv *env;
10762         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10763         if (get_jenv_res == JNI_EDETACHED) {
10764                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10765         } else {
10766                 DO_ASSERT(get_jenv_res == JNI_OK);
10767         }
10768         LDKCVec_RouteHopZ path_var = path;
10769         int64_tArray path_arr = NULL;
10770         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10771         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10772         for (size_t k = 0; k < path_var.datalen; k++) {
10773                 LDKRouteHop path_conv_10_var = path_var.data[k];
10774                 int64_t path_conv_10_ref = 0;
10775                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10776                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10777                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10778                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10779                 if (path_conv_10_var.is_owned) {
10780                         path_conv_10_ref |= 1;
10781                 }
10782                 path_arr_ptr[k] = path_conv_10_ref;
10783         }
10784         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10785         FREE(path_var.data);
10786         int64_t short_channel_id_conv = short_channel_id;
10787         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10788         CHECK(obj != NULL);
10789         (*env)->CallVoidMethod(env, obj, j_calls->probe_failed_meth, path_arr, short_channel_id_conv);
10790         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10791                 (*env)->ExceptionDescribe(env);
10792                 (*env)->FatalError(env, "A call to probe_failed in LDKScore from rust threw an exception.");
10793         }
10794         if (get_jenv_res == JNI_EDETACHED) {
10795                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10796         }
10797 }
10798 void probe_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
10799         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10800         JNIEnv *env;
10801         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10802         if (get_jenv_res == JNI_EDETACHED) {
10803                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10804         } else {
10805                 DO_ASSERT(get_jenv_res == JNI_OK);
10806         }
10807         LDKCVec_RouteHopZ path_var = path;
10808         int64_tArray path_arr = NULL;
10809         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10810         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10811         for (size_t k = 0; k < path_var.datalen; k++) {
10812                 LDKRouteHop path_conv_10_var = path_var.data[k];
10813                 int64_t path_conv_10_ref = 0;
10814                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10815                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10816                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10817                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10818                 if (path_conv_10_var.is_owned) {
10819                         path_conv_10_ref |= 1;
10820                 }
10821                 path_arr_ptr[k] = path_conv_10_ref;
10822         }
10823         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10824         FREE(path_var.data);
10825         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10826         CHECK(obj != NULL);
10827         (*env)->CallVoidMethod(env, obj, j_calls->probe_successful_meth, path_arr);
10828         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10829                 (*env)->ExceptionDescribe(env);
10830                 (*env)->FatalError(env, "A call to probe_successful in LDKScore from rust threw an exception.");
10831         }
10832         if (get_jenv_res == JNI_EDETACHED) {
10833                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10834         }
10835 }
10836 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
10837         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10838         JNIEnv *env;
10839         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10840         if (get_jenv_res == JNI_EDETACHED) {
10841                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10842         } else {
10843                 DO_ASSERT(get_jenv_res == JNI_OK);
10844         }
10845         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10846         CHECK(obj != NULL);
10847         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
10848         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10849                 (*env)->ExceptionDescribe(env);
10850                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
10851         }
10852         LDKCVec_u8Z ret_ref;
10853         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
10854         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
10855         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
10856         if (get_jenv_res == JNI_EDETACHED) {
10857                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10858         }
10859         return ret_ref;
10860 }
10861 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
10862         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
10863         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10864 }
10865 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
10866         jclass c = (*env)->GetObjectClass(env, o);
10867         CHECK(c != NULL);
10868         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
10869         atomic_init(&calls->refcnt, 1);
10870         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10871         calls->o = (*env)->NewWeakGlobalRef(env, o);
10872         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJ)J");
10873         CHECK(calls->channel_penalty_msat_meth != NULL);
10874         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
10875         CHECK(calls->payment_path_failed_meth != NULL);
10876         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
10877         CHECK(calls->payment_path_successful_meth != NULL);
10878         calls->probe_failed_meth = (*env)->GetMethodID(env, c, "probe_failed", "([JJ)V");
10879         CHECK(calls->probe_failed_meth != NULL);
10880         calls->probe_successful_meth = (*env)->GetMethodID(env, c, "probe_successful", "([J)V");
10881         CHECK(calls->probe_successful_meth != NULL);
10882         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
10883         CHECK(calls->write_meth != NULL);
10884
10885         LDKScore ret = {
10886                 .this_arg = (void*) calls,
10887                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
10888                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
10889                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
10890                 .probe_failed = probe_failed_LDKScore_jcall,
10891                 .probe_successful = probe_successful_LDKScore_jcall,
10892                 .write = write_LDKScore_jcall,
10893                 .free = LDKScore_JCalls_free,
10894         };
10895         return ret;
10896 }
10897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
10898         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
10899         *res_ptr = LDKScore_init(env, clz, o);
10900         return (uint64_t)res_ptr;
10901 }
10902 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) {
10903         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10904         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10905         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10906         LDKNodeId source_conv;
10907         source_conv.inner = (void*)(source & (~1));
10908         source_conv.is_owned = false;
10909         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
10910         LDKNodeId target_conv;
10911         target_conv.inner = (void*)(target & (~1));
10912         target_conv.is_owned = false;
10913         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
10914         LDKChannelUsage usage_conv;
10915         usage_conv.inner = (void*)(usage & (~1));
10916         usage_conv.is_owned = (usage & 1) || (usage == 0);
10917         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
10918         usage_conv = ChannelUsage_clone(&usage_conv);
10919         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
10920         return ret_conv;
10921 }
10922
10923 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) {
10924         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10925         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10926         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10927         LDKCVec_RouteHopZ path_constr;
10928         path_constr.datalen = (*env)->GetArrayLength(env, path);
10929         if (path_constr.datalen > 0)
10930                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10931         else
10932                 path_constr.data = NULL;
10933         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10934         for (size_t k = 0; k < path_constr.datalen; k++) {
10935                 int64_t path_conv_10 = path_vals[k];
10936                 LDKRouteHop path_conv_10_conv;
10937                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10938                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10939                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10940                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10941                 path_constr.data[k] = path_conv_10_conv;
10942         }
10943         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10944         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
10945 }
10946
10947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
10948         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10949         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10950         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10951         LDKCVec_RouteHopZ path_constr;
10952         path_constr.datalen = (*env)->GetArrayLength(env, path);
10953         if (path_constr.datalen > 0)
10954                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10955         else
10956                 path_constr.data = NULL;
10957         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10958         for (size_t k = 0; k < path_constr.datalen; k++) {
10959                 int64_t path_conv_10 = path_vals[k];
10960                 LDKRouteHop path_conv_10_conv;
10961                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10962                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10963                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10964                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10965                 path_constr.data[k] = path_conv_10_conv;
10966         }
10967         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10968         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
10969 }
10970
10971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
10972         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10973         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10974         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10975         LDKCVec_RouteHopZ path_constr;
10976         path_constr.datalen = (*env)->GetArrayLength(env, path);
10977         if (path_constr.datalen > 0)
10978                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10979         else
10980                 path_constr.data = NULL;
10981         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10982         for (size_t k = 0; k < path_constr.datalen; k++) {
10983                 int64_t path_conv_10 = path_vals[k];
10984                 LDKRouteHop path_conv_10_conv;
10985                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10986                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10987                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10988                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10989                 path_constr.data[k] = path_conv_10_conv;
10990         }
10991         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10992         (this_arg_conv->probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
10993 }
10994
10995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
10996         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10997         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10998         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10999         LDKCVec_RouteHopZ path_constr;
11000         path_constr.datalen = (*env)->GetArrayLength(env, path);
11001         if (path_constr.datalen > 0)
11002                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11003         else
11004                 path_constr.data = NULL;
11005         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
11006         for (size_t k = 0; k < path_constr.datalen; k++) {
11007                 int64_t path_conv_10 = path_vals[k];
11008                 LDKRouteHop path_conv_10_conv;
11009                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
11010                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
11011                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
11012                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
11013                 path_constr.data[k] = path_conv_10_conv;
11014         }
11015         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
11016         (this_arg_conv->probe_successful)(this_arg_conv->this_arg, path_constr);
11017 }
11018
11019 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
11020         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11021         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11022         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
11023         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
11024         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11025         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11026         CVec_u8Z_free(ret_var);
11027         return ret_arr;
11028 }
11029
11030 typedef struct LDKPersister_JCalls {
11031         atomic_size_t refcnt;
11032         JavaVM *vm;
11033         jweak o;
11034         jmethodID persist_manager_meth;
11035         jmethodID persist_graph_meth;
11036         jmethodID persist_scorer_meth;
11037 } LDKPersister_JCalls;
11038 static void LDKPersister_JCalls_free(void* this_arg) {
11039         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11040         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11041                 JNIEnv *env;
11042                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11043                 if (get_jenv_res == JNI_EDETACHED) {
11044                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11045                 } else {
11046                         DO_ASSERT(get_jenv_res == JNI_OK);
11047                 }
11048                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11049                 if (get_jenv_res == JNI_EDETACHED) {
11050                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11051                 }
11052                 FREE(j_calls);
11053         }
11054 }
11055 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
11056         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11057         JNIEnv *env;
11058         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11059         if (get_jenv_res == JNI_EDETACHED) {
11060                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11061         } else {
11062                 DO_ASSERT(get_jenv_res == JNI_OK);
11063         }
11064         LDKChannelManager channel_manager_var = *channel_manager;
11065         int64_t channel_manager_ref = 0;
11066         // WARNING: we may need a move here but no clone is available for LDKChannelManager
11067         CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11068         CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11069         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
11070         channel_manager_ref = (uintptr_t)channel_manager_var.inner;
11071         if (channel_manager_var.is_owned) {
11072                 channel_manager_ref |= 1;
11073         }
11074         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11075         CHECK(obj != NULL);
11076         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
11077         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11078                 (*env)->ExceptionDescribe(env);
11079                 (*env)->FatalError(env, "A call to persist_manager in LDKPersister from rust threw an exception.");
11080         }
11081         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11082         CHECK_ACCESS(ret_ptr);
11083         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11084         FREE((void*)ret);
11085         if (get_jenv_res == JNI_EDETACHED) {
11086                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11087         }
11088         return ret_conv;
11089 }
11090 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
11091         LDKPersister_JCalls *j_calls = (LDKPersister_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         LDKNetworkGraph network_graph_var = *network_graph;
11100         int64_t network_graph_ref = 0;
11101         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
11102         CHECK((((uintptr_t)network_graph_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11103         CHECK((((uintptr_t)&network_graph_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11104         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
11105         network_graph_ref = (uintptr_t)network_graph_var.inner;
11106         if (network_graph_var.is_owned) {
11107                 network_graph_ref |= 1;
11108         }
11109         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11110         CHECK(obj != NULL);
11111         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_graph_meth, network_graph_ref);
11112         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11113                 (*env)->ExceptionDescribe(env);
11114                 (*env)->FatalError(env, "A call to persist_graph in LDKPersister from rust threw an exception.");
11115         }
11116         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11117         CHECK_ACCESS(ret_ptr);
11118         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11119         FREE((void*)ret);
11120         if (get_jenv_res == JNI_EDETACHED) {
11121                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11122         }
11123         return ret_conv;
11124 }
11125 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKMultiThreadedLockableScore * scorer) {
11126         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11127         JNIEnv *env;
11128         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11129         if (get_jenv_res == JNI_EDETACHED) {
11130                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11131         } else {
11132                 DO_ASSERT(get_jenv_res == JNI_OK);
11133         }
11134         LDKMultiThreadedLockableScore scorer_var = *scorer;
11135         int64_t scorer_ref = 0;
11136         // WARNING: we may need a move here but no clone is available for LDKMultiThreadedLockableScore
11137         CHECK((((uintptr_t)scorer_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11138         CHECK((((uintptr_t)&scorer_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11139         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_var);
11140         scorer_ref = (uintptr_t)scorer_var.inner;
11141         if (scorer_var.is_owned) {
11142                 scorer_ref |= 1;
11143         }
11144         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11145         CHECK(obj != NULL);
11146         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_scorer_meth, scorer_ref);
11147         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11148                 (*env)->ExceptionDescribe(env);
11149                 (*env)->FatalError(env, "A call to persist_scorer in LDKPersister from rust threw an exception.");
11150         }
11151         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11152         CHECK_ACCESS(ret_ptr);
11153         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11154         FREE((void*)ret);
11155         if (get_jenv_res == JNI_EDETACHED) {
11156                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11157         }
11158         return ret_conv;
11159 }
11160 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
11161         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
11162         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11163 }
11164 static inline LDKPersister LDKPersister_init (JNIEnv *env, jclass clz, jobject o) {
11165         jclass c = (*env)->GetObjectClass(env, o);
11166         CHECK(c != NULL);
11167         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
11168         atomic_init(&calls->refcnt, 1);
11169         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11170         calls->o = (*env)->NewWeakGlobalRef(env, o);
11171         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
11172         CHECK(calls->persist_manager_meth != NULL);
11173         calls->persist_graph_meth = (*env)->GetMethodID(env, c, "persist_graph", "(J)J");
11174         CHECK(calls->persist_graph_meth != NULL);
11175         calls->persist_scorer_meth = (*env)->GetMethodID(env, c, "persist_scorer", "(J)J");
11176         CHECK(calls->persist_scorer_meth != NULL);
11177
11178         LDKPersister ret = {
11179                 .this_arg = (void*) calls,
11180                 .persist_manager = persist_manager_LDKPersister_jcall,
11181                 .persist_graph = persist_graph_LDKPersister_jcall,
11182                 .persist_scorer = persist_scorer_LDKPersister_jcall,
11183                 .free = LDKPersister_JCalls_free,
11184         };
11185         return ret;
11186 }
11187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersister_1new(JNIEnv *env, jclass clz, jobject o) {
11188         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
11189         *res_ptr = LDKPersister_init(env, clz, o);
11190         return (uint64_t)res_ptr;
11191 }
11192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
11193         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11194         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11195         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11196         LDKChannelManager channel_manager_conv;
11197         channel_manager_conv.inner = (void*)(channel_manager & (~1));
11198         channel_manager_conv.is_owned = false;
11199         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
11200         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11201         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
11202         return (int64_t)ret_conv;
11203 }
11204
11205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_graph) {
11206         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11207         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11208         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11209         LDKNetworkGraph network_graph_conv;
11210         network_graph_conv.inner = (void*)(network_graph & (~1));
11211         network_graph_conv.is_owned = false;
11212         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
11213         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11214         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
11215         return (int64_t)ret_conv;
11216 }
11217
11218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1scorer(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scorer) {
11219         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11220         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11221         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11222         LDKMultiThreadedLockableScore scorer_conv;
11223         scorer_conv.inner = (void*)(scorer & (~1));
11224         scorer_conv.is_owned = false;
11225         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
11226         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11227         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, &scorer_conv);
11228         return (int64_t)ret_conv;
11229 }
11230
11231 typedef struct LDKListen_JCalls {
11232         atomic_size_t refcnt;
11233         JavaVM *vm;
11234         jweak o;
11235         jmethodID filtered_block_connected_meth;
11236         jmethodID block_connected_meth;
11237         jmethodID block_disconnected_meth;
11238 } LDKListen_JCalls;
11239 static void LDKListen_JCalls_free(void* this_arg) {
11240         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11241         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11242                 JNIEnv *env;
11243                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11244                 if (get_jenv_res == JNI_EDETACHED) {
11245                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11246                 } else {
11247                         DO_ASSERT(get_jenv_res == JNI_OK);
11248                 }
11249                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11250                 if (get_jenv_res == JNI_EDETACHED) {
11251                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11252                 }
11253                 FREE(j_calls);
11254         }
11255 }
11256 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11257         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11258         JNIEnv *env;
11259         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11260         if (get_jenv_res == JNI_EDETACHED) {
11261                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11262         } else {
11263                 DO_ASSERT(get_jenv_res == JNI_OK);
11264         }
11265         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11266         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11267         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11268         int64_tArray txdata_arr = NULL;
11269         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11270         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11271         for (size_t c = 0; c < txdata_var.datalen; c++) {
11272                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11273                 *txdata_conv_28_conv = txdata_var.data[c];
11274                 txdata_arr_ptr[c] = ((int64_t)txdata_conv_28_conv);
11275         }
11276         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11277         FREE(txdata_var.data);
11278         int32_t height_conv = height;
11279         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11280         CHECK(obj != NULL);
11281         (*env)->CallVoidMethod(env, obj, j_calls->filtered_block_connected_meth, header_arr, txdata_arr, height_conv);
11282         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11283                 (*env)->ExceptionDescribe(env);
11284                 (*env)->FatalError(env, "A call to filtered_block_connected in LDKListen from rust threw an exception.");
11285         }
11286         if (get_jenv_res == JNI_EDETACHED) {
11287                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11288         }
11289 }
11290 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
11291         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11292         JNIEnv *env;
11293         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11294         if (get_jenv_res == JNI_EDETACHED) {
11295                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11296         } else {
11297                 DO_ASSERT(get_jenv_res == JNI_OK);
11298         }
11299         LDKu8slice block_var = block;
11300         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
11301         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
11302         int32_t height_conv = height;
11303         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11304         CHECK(obj != NULL);
11305         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height_conv);
11306         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11307                 (*env)->ExceptionDescribe(env);
11308                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
11309         }
11310         if (get_jenv_res == JNI_EDETACHED) {
11311                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11312         }
11313 }
11314 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11315         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11316         JNIEnv *env;
11317         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11318         if (get_jenv_res == JNI_EDETACHED) {
11319                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11320         } else {
11321                 DO_ASSERT(get_jenv_res == JNI_OK);
11322         }
11323         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11324         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11325         int32_t height_conv = height;
11326         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11327         CHECK(obj != NULL);
11328         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height_conv);
11329         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11330                 (*env)->ExceptionDescribe(env);
11331                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
11332         }
11333         if (get_jenv_res == JNI_EDETACHED) {
11334                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11335         }
11336 }
11337 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
11338         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
11339         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11340 }
11341 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
11342         jclass c = (*env)->GetObjectClass(env, o);
11343         CHECK(c != NULL);
11344         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
11345         atomic_init(&calls->refcnt, 1);
11346         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11347         calls->o = (*env)->NewWeakGlobalRef(env, o);
11348         calls->filtered_block_connected_meth = (*env)->GetMethodID(env, c, "filtered_block_connected", "([B[JI)V");
11349         CHECK(calls->filtered_block_connected_meth != NULL);
11350         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
11351         CHECK(calls->block_connected_meth != NULL);
11352         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
11353         CHECK(calls->block_disconnected_meth != NULL);
11354
11355         LDKListen ret = {
11356                 .this_arg = (void*) calls,
11357                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
11358                 .block_connected = block_connected_LDKListen_jcall,
11359                 .block_disconnected = block_disconnected_LDKListen_jcall,
11360                 .free = LDKListen_JCalls_free,
11361         };
11362         return ret;
11363 }
11364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
11365         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
11366         *res_ptr = LDKListen_init(env, clz, o);
11367         return (uint64_t)res_ptr;
11368 }
11369 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) {
11370         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11371         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11372         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11373         unsigned char header_arr[80];
11374         CHECK((*env)->GetArrayLength(env, header) == 80);
11375         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11376         unsigned char (*header_ref)[80] = &header_arr;
11377         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11378         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11379         if (txdata_constr.datalen > 0)
11380                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11381         else
11382                 txdata_constr.data = NULL;
11383         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11384         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11385                 int64_t txdata_conv_28 = txdata_vals[c];
11386                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
11387                 CHECK_ACCESS(txdata_conv_28_ptr);
11388                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11389                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
11390                 txdata_constr.data[c] = txdata_conv_28_conv;
11391         }
11392         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11393         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11394 }
11395
11396 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) {
11397         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11398         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11399         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11400         LDKu8slice block_ref;
11401         block_ref.datalen = (*env)->GetArrayLength(env, block);
11402         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
11403         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
11404         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
11405 }
11406
11407 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) {
11408         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11409         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11410         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11411         unsigned char header_arr[80];
11412         CHECK((*env)->GetArrayLength(env, header) == 80);
11413         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11414         unsigned char (*header_ref)[80] = &header_arr;
11415         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
11416 }
11417
11418 typedef struct LDKConfirm_JCalls {
11419         atomic_size_t refcnt;
11420         JavaVM *vm;
11421         jweak o;
11422         jmethodID transactions_confirmed_meth;
11423         jmethodID transaction_unconfirmed_meth;
11424         jmethodID best_block_updated_meth;
11425         jmethodID get_relevant_txids_meth;
11426 } LDKConfirm_JCalls;
11427 static void LDKConfirm_JCalls_free(void* this_arg) {
11428         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11429         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11430                 JNIEnv *env;
11431                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11432                 if (get_jenv_res == JNI_EDETACHED) {
11433                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11434                 } else {
11435                         DO_ASSERT(get_jenv_res == JNI_OK);
11436                 }
11437                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11438                 if (get_jenv_res == JNI_EDETACHED) {
11439                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11440                 }
11441                 FREE(j_calls);
11442         }
11443 }
11444 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11445         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11446         JNIEnv *env;
11447         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11448         if (get_jenv_res == JNI_EDETACHED) {
11449                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11450         } else {
11451                 DO_ASSERT(get_jenv_res == JNI_OK);
11452         }
11453         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11454         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11455         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11456         int64_tArray txdata_arr = NULL;
11457         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11458         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11459         for (size_t c = 0; c < txdata_var.datalen; c++) {
11460                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11461                 *txdata_conv_28_conv = txdata_var.data[c];
11462                 txdata_arr_ptr[c] = ((int64_t)txdata_conv_28_conv);
11463         }
11464         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11465         FREE(txdata_var.data);
11466         int32_t height_conv = height;
11467         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11468         CHECK(obj != NULL);
11469         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height_conv);
11470         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11471                 (*env)->ExceptionDescribe(env);
11472                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
11473         }
11474         if (get_jenv_res == JNI_EDETACHED) {
11475                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11476         }
11477 }
11478 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
11479         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11480         JNIEnv *env;
11481         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11482         if (get_jenv_res == JNI_EDETACHED) {
11483                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11484         } else {
11485                 DO_ASSERT(get_jenv_res == JNI_OK);
11486         }
11487         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
11488         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
11489         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11490         CHECK(obj != NULL);
11491         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
11492         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11493                 (*env)->ExceptionDescribe(env);
11494                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
11495         }
11496         if (get_jenv_res == JNI_EDETACHED) {
11497                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11498         }
11499 }
11500 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11501         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11502         JNIEnv *env;
11503         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11504         if (get_jenv_res == JNI_EDETACHED) {
11505                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11506         } else {
11507                 DO_ASSERT(get_jenv_res == JNI_OK);
11508         }
11509         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11510         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11511         int32_t height_conv = height;
11512         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11513         CHECK(obj != NULL);
11514         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height_conv);
11515         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11516                 (*env)->ExceptionDescribe(env);
11517                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
11518         }
11519         if (get_jenv_res == JNI_EDETACHED) {
11520                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11521         }
11522 }
11523 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
11524         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11525         JNIEnv *env;
11526         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11527         if (get_jenv_res == JNI_EDETACHED) {
11528                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11529         } else {
11530                 DO_ASSERT(get_jenv_res == JNI_OK);
11531         }
11532         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11533         CHECK(obj != NULL);
11534         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
11535         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11536                 (*env)->ExceptionDescribe(env);
11537                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
11538         }
11539         LDKCVec_TxidZ ret_constr;
11540         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11541         if (ret_constr.datalen > 0)
11542                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
11543         else
11544                 ret_constr.data = NULL;
11545         for (size_t i = 0; i < ret_constr.datalen; i++) {
11546                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
11547                 LDKThirtyTwoBytes ret_conv_8_ref;
11548                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
11549                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
11550                 ret_constr.data[i] = ret_conv_8_ref;
11551         }
11552         if (get_jenv_res == JNI_EDETACHED) {
11553                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11554         }
11555         return ret_constr;
11556 }
11557 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
11558         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
11559         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11560 }
11561 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
11562         jclass c = (*env)->GetObjectClass(env, o);
11563         CHECK(c != NULL);
11564         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
11565         atomic_init(&calls->refcnt, 1);
11566         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11567         calls->o = (*env)->NewWeakGlobalRef(env, o);
11568         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
11569         CHECK(calls->transactions_confirmed_meth != NULL);
11570         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
11571         CHECK(calls->transaction_unconfirmed_meth != NULL);
11572         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
11573         CHECK(calls->best_block_updated_meth != NULL);
11574         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
11575         CHECK(calls->get_relevant_txids_meth != NULL);
11576
11577         LDKConfirm ret = {
11578                 .this_arg = (void*) calls,
11579                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
11580                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
11581                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
11582                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
11583                 .free = LDKConfirm_JCalls_free,
11584         };
11585         return ret;
11586 }
11587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
11588         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
11589         *res_ptr = LDKConfirm_init(env, clz, o);
11590         return (uint64_t)res_ptr;
11591 }
11592 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) {
11593         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11594         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11595         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11596         unsigned char header_arr[80];
11597         CHECK((*env)->GetArrayLength(env, header) == 80);
11598         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11599         unsigned char (*header_ref)[80] = &header_arr;
11600         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11601         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11602         if (txdata_constr.datalen > 0)
11603                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11604         else
11605                 txdata_constr.data = NULL;
11606         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11607         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11608                 int64_t txdata_conv_28 = txdata_vals[c];
11609                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
11610                 CHECK_ACCESS(txdata_conv_28_ptr);
11611                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11612                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
11613                 txdata_constr.data[c] = txdata_conv_28_conv;
11614         }
11615         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11616         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11617 }
11618
11619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
11620         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11621         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11622         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11623         unsigned char txid_arr[32];
11624         CHECK((*env)->GetArrayLength(env, txid) == 32);
11625         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
11626         unsigned char (*txid_ref)[32] = &txid_arr;
11627         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
11628 }
11629
11630 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) {
11631         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11632         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11633         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11634         unsigned char header_arr[80];
11635         CHECK((*env)->GetArrayLength(env, header) == 80);
11636         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11637         unsigned char (*header_ref)[80] = &header_arr;
11638         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
11639 }
11640
11641 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
11642         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11643         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11644         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11645         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
11646         jobjectArray ret_arr = NULL;
11647         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
11648         ;
11649         for (size_t i = 0; i < ret_var.datalen; i++) {
11650                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
11651                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
11652                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
11653         }
11654         
11655         FREE(ret_var.data);
11656         return ret_arr;
11657 }
11658
11659 typedef struct LDKPersist_JCalls {
11660         atomic_size_t refcnt;
11661         JavaVM *vm;
11662         jweak o;
11663         jmethodID persist_new_channel_meth;
11664         jmethodID update_persisted_channel_meth;
11665 } LDKPersist_JCalls;
11666 static void LDKPersist_JCalls_free(void* this_arg) {
11667         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11668         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11669                 JNIEnv *env;
11670                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11671                 if (get_jenv_res == JNI_EDETACHED) {
11672                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11673                 } else {
11674                         DO_ASSERT(get_jenv_res == JNI_OK);
11675                 }
11676                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11677                 if (get_jenv_res == JNI_EDETACHED) {
11678                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11679                 }
11680                 FREE(j_calls);
11681         }
11682 }
11683 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11684         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11685         JNIEnv *env;
11686         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11687         if (get_jenv_res == JNI_EDETACHED) {
11688                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11689         } else {
11690                 DO_ASSERT(get_jenv_res == JNI_OK);
11691         }
11692         LDKOutPoint channel_id_var = channel_id;
11693         int64_t channel_id_ref = 0;
11694         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11695         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11696         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11697         channel_id_ref = (uintptr_t)channel_id_var.inner;
11698         if (channel_id_var.is_owned) {
11699                 channel_id_ref |= 1;
11700         }
11701         LDKChannelMonitor data_var = *data;
11702         int64_t data_ref = 0;
11703         data_var = ChannelMonitor_clone(&data_var);
11704         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11705         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11706         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11707         data_ref = (uintptr_t)data_var.inner;
11708         if (data_var.is_owned) {
11709                 data_ref |= 1;
11710         }
11711         LDKMonitorUpdateId update_id_var = update_id;
11712         int64_t update_id_ref = 0;
11713         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11714         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11715         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11716         update_id_ref = (uintptr_t)update_id_var.inner;
11717         if (update_id_var.is_owned) {
11718                 update_id_ref |= 1;
11719         }
11720         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11721         CHECK(obj != NULL);
11722         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
11723         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11724                 (*env)->ExceptionDescribe(env);
11725                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
11726         }
11727         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11728         CHECK_ACCESS(ret_ptr);
11729         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
11730         FREE((void*)ret);
11731         if (get_jenv_res == JNI_EDETACHED) {
11732                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11733         }
11734         return ret_conv;
11735 }
11736 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11737         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11738         JNIEnv *env;
11739         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11740         if (get_jenv_res == JNI_EDETACHED) {
11741                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11742         } else {
11743                 DO_ASSERT(get_jenv_res == JNI_OK);
11744         }
11745         LDKOutPoint channel_id_var = channel_id;
11746         int64_t channel_id_ref = 0;
11747         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11748         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11749         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11750         channel_id_ref = (uintptr_t)channel_id_var.inner;
11751         if (channel_id_var.is_owned) {
11752                 channel_id_ref |= 1;
11753         }
11754         LDKChannelMonitorUpdate update_var = *update;
11755         int64_t update_ref = 0;
11756         if ((uintptr_t)update_var.inner > 4096) {
11757                 update_var = ChannelMonitorUpdate_clone(&update_var);
11758                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11759                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11760         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
11761                 update_ref = (uintptr_t)update_var.inner;
11762                 if (update_var.is_owned) {
11763                         update_ref |= 1;
11764                 }
11765         }
11766         LDKChannelMonitor data_var = *data;
11767         int64_t data_ref = 0;
11768         data_var = ChannelMonitor_clone(&data_var);
11769         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11770         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11771         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11772         data_ref = (uintptr_t)data_var.inner;
11773         if (data_var.is_owned) {
11774                 data_ref |= 1;
11775         }
11776         LDKMonitorUpdateId update_id_var = update_id;
11777         int64_t update_id_ref = 0;
11778         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11779         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11780         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11781         update_id_ref = (uintptr_t)update_id_var.inner;
11782         if (update_id_var.is_owned) {
11783                 update_id_ref |= 1;
11784         }
11785         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11786         CHECK(obj != NULL);
11787         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
11788         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11789                 (*env)->ExceptionDescribe(env);
11790                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
11791         }
11792         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11793         CHECK_ACCESS(ret_ptr);
11794         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
11795         FREE((void*)ret);
11796         if (get_jenv_res == JNI_EDETACHED) {
11797                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11798         }
11799         return ret_conv;
11800 }
11801 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
11802         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
11803         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11804 }
11805 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
11806         jclass c = (*env)->GetObjectClass(env, o);
11807         CHECK(c != NULL);
11808         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
11809         atomic_init(&calls->refcnt, 1);
11810         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11811         calls->o = (*env)->NewWeakGlobalRef(env, o);
11812         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
11813         CHECK(calls->persist_new_channel_meth != NULL);
11814         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
11815         CHECK(calls->update_persisted_channel_meth != NULL);
11816
11817         LDKPersist ret = {
11818                 .this_arg = (void*) calls,
11819                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
11820                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
11821                 .free = LDKPersist_JCalls_free,
11822         };
11823         return ret;
11824 }
11825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
11826         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
11827         *res_ptr = LDKPersist_init(env, clz, o);
11828         return (uint64_t)res_ptr;
11829 }
11830 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) {
11831         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11832         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11833         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
11834         LDKOutPoint channel_id_conv;
11835         channel_id_conv.inner = (void*)(channel_id & (~1));
11836         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
11837         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
11838         channel_id_conv = OutPoint_clone(&channel_id_conv);
11839         LDKChannelMonitor data_conv;
11840         data_conv.inner = (void*)(data & (~1));
11841         data_conv.is_owned = false;
11842         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
11843         LDKMonitorUpdateId update_id_conv;
11844         update_id_conv.inner = (void*)(update_id & (~1));
11845         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
11846         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
11847         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
11848         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11849         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
11850         return (int64_t)ret_conv;
11851 }
11852
11853 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) {
11854         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11855         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11856         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
11857         LDKOutPoint channel_id_conv;
11858         channel_id_conv.inner = (void*)(channel_id & (~1));
11859         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
11860         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
11861         channel_id_conv = OutPoint_clone(&channel_id_conv);
11862         LDKChannelMonitorUpdate update_conv;
11863         update_conv.inner = (void*)(update & (~1));
11864         update_conv.is_owned = false;
11865         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
11866         LDKChannelMonitor data_conv;
11867         data_conv.inner = (void*)(data & (~1));
11868         data_conv.is_owned = false;
11869         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
11870         LDKMonitorUpdateId update_id_conv;
11871         update_id_conv.inner = (void*)(update_id & (~1));
11872         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
11873         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
11874         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
11875         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11876         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
11877         return (int64_t)ret_conv;
11878 }
11879
11880 typedef struct LDKChannelMessageHandler_JCalls {
11881         atomic_size_t refcnt;
11882         JavaVM *vm;
11883         jweak o;
11884         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
11885         jmethodID handle_open_channel_meth;
11886         jmethodID handle_accept_channel_meth;
11887         jmethodID handle_funding_created_meth;
11888         jmethodID handle_funding_signed_meth;
11889         jmethodID handle_channel_ready_meth;
11890         jmethodID handle_shutdown_meth;
11891         jmethodID handle_closing_signed_meth;
11892         jmethodID handle_update_add_htlc_meth;
11893         jmethodID handle_update_fulfill_htlc_meth;
11894         jmethodID handle_update_fail_htlc_meth;
11895         jmethodID handle_update_fail_malformed_htlc_meth;
11896         jmethodID handle_commitment_signed_meth;
11897         jmethodID handle_revoke_and_ack_meth;
11898         jmethodID handle_update_fee_meth;
11899         jmethodID handle_announcement_signatures_meth;
11900         jmethodID peer_disconnected_meth;
11901         jmethodID peer_connected_meth;
11902         jmethodID handle_channel_reestablish_meth;
11903         jmethodID handle_channel_update_meth;
11904         jmethodID handle_error_meth;
11905 } LDKChannelMessageHandler_JCalls;
11906 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
11907         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11908         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11909                 JNIEnv *env;
11910                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11911                 if (get_jenv_res == JNI_EDETACHED) {
11912                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11913                 } else {
11914                         DO_ASSERT(get_jenv_res == JNI_OK);
11915                 }
11916                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11917                 if (get_jenv_res == JNI_EDETACHED) {
11918                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11919                 }
11920                 FREE(j_calls);
11921         }
11922 }
11923 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
11924         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11925         JNIEnv *env;
11926         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11927         if (get_jenv_res == JNI_EDETACHED) {
11928                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11929         } else {
11930                 DO_ASSERT(get_jenv_res == JNI_OK);
11931         }
11932         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11933         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11934         LDKInitFeatures their_features_var = their_features;
11935         int64_t their_features_ref = 0;
11936         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11937         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11938         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11939         their_features_ref = (uintptr_t)their_features_var.inner;
11940         if (their_features_var.is_owned) {
11941                 their_features_ref |= 1;
11942         }
11943         LDKOpenChannel msg_var = *msg;
11944         int64_t msg_ref = 0;
11945         msg_var = OpenChannel_clone(&msg_var);
11946         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11947         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11948         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11949         msg_ref = (uintptr_t)msg_var.inner;
11950         if (msg_var.is_owned) {
11951                 msg_ref |= 1;
11952         }
11953         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11954         CHECK(obj != NULL);
11955         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
11956         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11957                 (*env)->ExceptionDescribe(env);
11958                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
11959         }
11960         if (get_jenv_res == JNI_EDETACHED) {
11961                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11962         }
11963 }
11964 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
11965         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11966         JNIEnv *env;
11967         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11968         if (get_jenv_res == JNI_EDETACHED) {
11969                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11970         } else {
11971                 DO_ASSERT(get_jenv_res == JNI_OK);
11972         }
11973         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11974         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11975         LDKInitFeatures their_features_var = their_features;
11976         int64_t their_features_ref = 0;
11977         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11978         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11979         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11980         their_features_ref = (uintptr_t)their_features_var.inner;
11981         if (their_features_var.is_owned) {
11982                 their_features_ref |= 1;
11983         }
11984         LDKAcceptChannel msg_var = *msg;
11985         int64_t msg_ref = 0;
11986         msg_var = AcceptChannel_clone(&msg_var);
11987         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11988         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11989         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11990         msg_ref = (uintptr_t)msg_var.inner;
11991         if (msg_var.is_owned) {
11992                 msg_ref |= 1;
11993         }
11994         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11995         CHECK(obj != NULL);
11996         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
11997         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11998                 (*env)->ExceptionDescribe(env);
11999                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
12000         }
12001         if (get_jenv_res == JNI_EDETACHED) {
12002                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12003         }
12004 }
12005 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
12006         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12007         JNIEnv *env;
12008         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12009         if (get_jenv_res == JNI_EDETACHED) {
12010                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12011         } else {
12012                 DO_ASSERT(get_jenv_res == JNI_OK);
12013         }
12014         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12015         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12016         LDKFundingCreated msg_var = *msg;
12017         int64_t msg_ref = 0;
12018         msg_var = FundingCreated_clone(&msg_var);
12019         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12020         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12021         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12022         msg_ref = (uintptr_t)msg_var.inner;
12023         if (msg_var.is_owned) {
12024                 msg_ref |= 1;
12025         }
12026         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12027         CHECK(obj != NULL);
12028         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
12029         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12030                 (*env)->ExceptionDescribe(env);
12031                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
12032         }
12033         if (get_jenv_res == JNI_EDETACHED) {
12034                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12035         }
12036 }
12037 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
12038         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12039         JNIEnv *env;
12040         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12041         if (get_jenv_res == JNI_EDETACHED) {
12042                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12043         } else {
12044                 DO_ASSERT(get_jenv_res == JNI_OK);
12045         }
12046         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12047         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12048         LDKFundingSigned msg_var = *msg;
12049         int64_t msg_ref = 0;
12050         msg_var = FundingSigned_clone(&msg_var);
12051         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12052         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12053         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12054         msg_ref = (uintptr_t)msg_var.inner;
12055         if (msg_var.is_owned) {
12056                 msg_ref |= 1;
12057         }
12058         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12059         CHECK(obj != NULL);
12060         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
12061         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12062                 (*env)->ExceptionDescribe(env);
12063                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
12064         }
12065         if (get_jenv_res == JNI_EDETACHED) {
12066                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12067         }
12068 }
12069 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
12070         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12071         JNIEnv *env;
12072         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12073         if (get_jenv_res == JNI_EDETACHED) {
12074                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12075         } else {
12076                 DO_ASSERT(get_jenv_res == JNI_OK);
12077         }
12078         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12079         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12080         LDKChannelReady msg_var = *msg;
12081         int64_t msg_ref = 0;
12082         msg_var = ChannelReady_clone(&msg_var);
12083         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12084         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12085         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12086         msg_ref = (uintptr_t)msg_var.inner;
12087         if (msg_var.is_owned) {
12088                 msg_ref |= 1;
12089         }
12090         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12091         CHECK(obj != NULL);
12092         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_ready_meth, their_node_id_arr, msg_ref);
12093         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12094                 (*env)->ExceptionDescribe(env);
12095                 (*env)->FatalError(env, "A call to handle_channel_ready in LDKChannelMessageHandler from rust threw an exception.");
12096         }
12097         if (get_jenv_res == JNI_EDETACHED) {
12098                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12099         }
12100 }
12101 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
12102         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12103         JNIEnv *env;
12104         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12105         if (get_jenv_res == JNI_EDETACHED) {
12106                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12107         } else {
12108                 DO_ASSERT(get_jenv_res == JNI_OK);
12109         }
12110         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12111         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12112         LDKInitFeatures their_features_var = *their_features;
12113         int64_t their_features_ref = 0;
12114         their_features_var = InitFeatures_clone(&their_features_var);
12115         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12116         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12117         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
12118         their_features_ref = (uintptr_t)their_features_var.inner;
12119         if (their_features_var.is_owned) {
12120                 their_features_ref |= 1;
12121         }
12122         LDKShutdown msg_var = *msg;
12123         int64_t msg_ref = 0;
12124         msg_var = Shutdown_clone(&msg_var);
12125         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12126         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12127         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12128         msg_ref = (uintptr_t)msg_var.inner;
12129         if (msg_var.is_owned) {
12130                 msg_ref |= 1;
12131         }
12132         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12133         CHECK(obj != NULL);
12134         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
12135         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12136                 (*env)->ExceptionDescribe(env);
12137                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
12138         }
12139         if (get_jenv_res == JNI_EDETACHED) {
12140                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12141         }
12142 }
12143 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
12144         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12145         JNIEnv *env;
12146         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12147         if (get_jenv_res == JNI_EDETACHED) {
12148                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12149         } else {
12150                 DO_ASSERT(get_jenv_res == JNI_OK);
12151         }
12152         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12153         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12154         LDKClosingSigned msg_var = *msg;
12155         int64_t msg_ref = 0;
12156         msg_var = ClosingSigned_clone(&msg_var);
12157         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12158         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12159         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12160         msg_ref = (uintptr_t)msg_var.inner;
12161         if (msg_var.is_owned) {
12162                 msg_ref |= 1;
12163         }
12164         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12165         CHECK(obj != NULL);
12166         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
12167         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12168                 (*env)->ExceptionDescribe(env);
12169                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
12170         }
12171         if (get_jenv_res == JNI_EDETACHED) {
12172                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12173         }
12174 }
12175 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
12176         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12177         JNIEnv *env;
12178         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12179         if (get_jenv_res == JNI_EDETACHED) {
12180                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12181         } else {
12182                 DO_ASSERT(get_jenv_res == JNI_OK);
12183         }
12184         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12185         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12186         LDKUpdateAddHTLC msg_var = *msg;
12187         int64_t msg_ref = 0;
12188         msg_var = UpdateAddHTLC_clone(&msg_var);
12189         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12190         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12191         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12192         msg_ref = (uintptr_t)msg_var.inner;
12193         if (msg_var.is_owned) {
12194                 msg_ref |= 1;
12195         }
12196         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12197         CHECK(obj != NULL);
12198         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
12199         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12200                 (*env)->ExceptionDescribe(env);
12201                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
12202         }
12203         if (get_jenv_res == JNI_EDETACHED) {
12204                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12205         }
12206 }
12207 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
12208         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12209         JNIEnv *env;
12210         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12211         if (get_jenv_res == JNI_EDETACHED) {
12212                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12213         } else {
12214                 DO_ASSERT(get_jenv_res == JNI_OK);
12215         }
12216         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12217         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12218         LDKUpdateFulfillHTLC msg_var = *msg;
12219         int64_t msg_ref = 0;
12220         msg_var = UpdateFulfillHTLC_clone(&msg_var);
12221         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12222         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12223         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12224         msg_ref = (uintptr_t)msg_var.inner;
12225         if (msg_var.is_owned) {
12226                 msg_ref |= 1;
12227         }
12228         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12229         CHECK(obj != NULL);
12230         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
12231         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12232                 (*env)->ExceptionDescribe(env);
12233                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
12234         }
12235         if (get_jenv_res == JNI_EDETACHED) {
12236                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12237         }
12238 }
12239 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
12240         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12241         JNIEnv *env;
12242         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12243         if (get_jenv_res == JNI_EDETACHED) {
12244                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12245         } else {
12246                 DO_ASSERT(get_jenv_res == JNI_OK);
12247         }
12248         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12249         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12250         LDKUpdateFailHTLC msg_var = *msg;
12251         int64_t msg_ref = 0;
12252         msg_var = UpdateFailHTLC_clone(&msg_var);
12253         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12254         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12255         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12256         msg_ref = (uintptr_t)msg_var.inner;
12257         if (msg_var.is_owned) {
12258                 msg_ref |= 1;
12259         }
12260         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12261         CHECK(obj != NULL);
12262         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
12263         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12264                 (*env)->ExceptionDescribe(env);
12265                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
12266         }
12267         if (get_jenv_res == JNI_EDETACHED) {
12268                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12269         }
12270 }
12271 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
12272         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12273         JNIEnv *env;
12274         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12275         if (get_jenv_res == JNI_EDETACHED) {
12276                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12277         } else {
12278                 DO_ASSERT(get_jenv_res == JNI_OK);
12279         }
12280         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12281         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12282         LDKUpdateFailMalformedHTLC msg_var = *msg;
12283         int64_t msg_ref = 0;
12284         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
12285         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12286         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12287         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12288         msg_ref = (uintptr_t)msg_var.inner;
12289         if (msg_var.is_owned) {
12290                 msg_ref |= 1;
12291         }
12292         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12293         CHECK(obj != NULL);
12294         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
12295         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12296                 (*env)->ExceptionDescribe(env);
12297                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
12298         }
12299         if (get_jenv_res == JNI_EDETACHED) {
12300                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12301         }
12302 }
12303 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
12304         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12305         JNIEnv *env;
12306         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12307         if (get_jenv_res == JNI_EDETACHED) {
12308                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12309         } else {
12310                 DO_ASSERT(get_jenv_res == JNI_OK);
12311         }
12312         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12313         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12314         LDKCommitmentSigned msg_var = *msg;
12315         int64_t msg_ref = 0;
12316         msg_var = CommitmentSigned_clone(&msg_var);
12317         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12318         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12319         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12320         msg_ref = (uintptr_t)msg_var.inner;
12321         if (msg_var.is_owned) {
12322                 msg_ref |= 1;
12323         }
12324         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12325         CHECK(obj != NULL);
12326         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
12327         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12328                 (*env)->ExceptionDescribe(env);
12329                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
12330         }
12331         if (get_jenv_res == JNI_EDETACHED) {
12332                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12333         }
12334 }
12335 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
12336         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12337         JNIEnv *env;
12338         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12339         if (get_jenv_res == JNI_EDETACHED) {
12340                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12341         } else {
12342                 DO_ASSERT(get_jenv_res == JNI_OK);
12343         }
12344         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12345         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12346         LDKRevokeAndACK msg_var = *msg;
12347         int64_t msg_ref = 0;
12348         msg_var = RevokeAndACK_clone(&msg_var);
12349         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12350         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12351         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12352         msg_ref = (uintptr_t)msg_var.inner;
12353         if (msg_var.is_owned) {
12354                 msg_ref |= 1;
12355         }
12356         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12357         CHECK(obj != NULL);
12358         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
12359         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12360                 (*env)->ExceptionDescribe(env);
12361                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
12362         }
12363         if (get_jenv_res == JNI_EDETACHED) {
12364                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12365         }
12366 }
12367 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
12368         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12369         JNIEnv *env;
12370         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12371         if (get_jenv_res == JNI_EDETACHED) {
12372                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12373         } else {
12374                 DO_ASSERT(get_jenv_res == JNI_OK);
12375         }
12376         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12377         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12378         LDKUpdateFee msg_var = *msg;
12379         int64_t msg_ref = 0;
12380         msg_var = UpdateFee_clone(&msg_var);
12381         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12382         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12383         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12384         msg_ref = (uintptr_t)msg_var.inner;
12385         if (msg_var.is_owned) {
12386                 msg_ref |= 1;
12387         }
12388         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12389         CHECK(obj != NULL);
12390         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
12391         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12392                 (*env)->ExceptionDescribe(env);
12393                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
12394         }
12395         if (get_jenv_res == JNI_EDETACHED) {
12396                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12397         }
12398 }
12399 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
12400         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12401         JNIEnv *env;
12402         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12403         if (get_jenv_res == JNI_EDETACHED) {
12404                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12405         } else {
12406                 DO_ASSERT(get_jenv_res == JNI_OK);
12407         }
12408         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12409         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12410         LDKAnnouncementSignatures msg_var = *msg;
12411         int64_t msg_ref = 0;
12412         msg_var = AnnouncementSignatures_clone(&msg_var);
12413         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12414         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12415         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12416         msg_ref = (uintptr_t)msg_var.inner;
12417         if (msg_var.is_owned) {
12418                 msg_ref |= 1;
12419         }
12420         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12421         CHECK(obj != NULL);
12422         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
12423         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12424                 (*env)->ExceptionDescribe(env);
12425                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
12426         }
12427         if (get_jenv_res == JNI_EDETACHED) {
12428                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12429         }
12430 }
12431 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
12432         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12433         JNIEnv *env;
12434         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12435         if (get_jenv_res == JNI_EDETACHED) {
12436                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12437         } else {
12438                 DO_ASSERT(get_jenv_res == JNI_OK);
12439         }
12440         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12441         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12442         jboolean no_connection_possible_conv = no_connection_possible;
12443         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12444         CHECK(obj != NULL);
12445         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
12446         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12447                 (*env)->ExceptionDescribe(env);
12448                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
12449         }
12450         if (get_jenv_res == JNI_EDETACHED) {
12451                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12452         }
12453 }
12454 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
12455         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12456         JNIEnv *env;
12457         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12458         if (get_jenv_res == JNI_EDETACHED) {
12459                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12460         } else {
12461                 DO_ASSERT(get_jenv_res == JNI_OK);
12462         }
12463         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12464         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12465         LDKInit msg_var = *msg;
12466         int64_t msg_ref = 0;
12467         msg_var = Init_clone(&msg_var);
12468         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12469         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12470         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12471         msg_ref = (uintptr_t)msg_var.inner;
12472         if (msg_var.is_owned) {
12473                 msg_ref |= 1;
12474         }
12475         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12476         CHECK(obj != NULL);
12477         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
12478         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12479                 (*env)->ExceptionDescribe(env);
12480                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
12481         }
12482         if (get_jenv_res == JNI_EDETACHED) {
12483                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12484         }
12485 }
12486 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
12487         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12488         JNIEnv *env;
12489         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12490         if (get_jenv_res == JNI_EDETACHED) {
12491                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12492         } else {
12493                 DO_ASSERT(get_jenv_res == JNI_OK);
12494         }
12495         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12496         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12497         LDKChannelReestablish msg_var = *msg;
12498         int64_t msg_ref = 0;
12499         msg_var = ChannelReestablish_clone(&msg_var);
12500         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12501         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12502         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12503         msg_ref = (uintptr_t)msg_var.inner;
12504         if (msg_var.is_owned) {
12505                 msg_ref |= 1;
12506         }
12507         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12508         CHECK(obj != NULL);
12509         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
12510         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12511                 (*env)->ExceptionDescribe(env);
12512                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
12513         }
12514         if (get_jenv_res == JNI_EDETACHED) {
12515                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12516         }
12517 }
12518 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
12519         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12520         JNIEnv *env;
12521         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12522         if (get_jenv_res == JNI_EDETACHED) {
12523                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12524         } else {
12525                 DO_ASSERT(get_jenv_res == JNI_OK);
12526         }
12527         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12528         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12529         LDKChannelUpdate msg_var = *msg;
12530         int64_t msg_ref = 0;
12531         msg_var = ChannelUpdate_clone(&msg_var);
12532         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12533         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12534         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12535         msg_ref = (uintptr_t)msg_var.inner;
12536         if (msg_var.is_owned) {
12537                 msg_ref |= 1;
12538         }
12539         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12540         CHECK(obj != NULL);
12541         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
12542         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12543                 (*env)->ExceptionDescribe(env);
12544                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
12545         }
12546         if (get_jenv_res == JNI_EDETACHED) {
12547                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12548         }
12549 }
12550 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
12551         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12552         JNIEnv *env;
12553         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12554         if (get_jenv_res == JNI_EDETACHED) {
12555                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12556         } else {
12557                 DO_ASSERT(get_jenv_res == JNI_OK);
12558         }
12559         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12560         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12561         LDKErrorMessage msg_var = *msg;
12562         int64_t msg_ref = 0;
12563         msg_var = ErrorMessage_clone(&msg_var);
12564         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12565         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12566         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12567         msg_ref = (uintptr_t)msg_var.inner;
12568         if (msg_var.is_owned) {
12569                 msg_ref |= 1;
12570         }
12571         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12572         CHECK(obj != NULL);
12573         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
12574         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12575                 (*env)->ExceptionDescribe(env);
12576                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
12577         }
12578         if (get_jenv_res == JNI_EDETACHED) {
12579                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12580         }
12581 }
12582 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
12583         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
12584         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12585         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
12586 }
12587 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12588         jclass c = (*env)->GetObjectClass(env, o);
12589         CHECK(c != NULL);
12590         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
12591         atomic_init(&calls->refcnt, 1);
12592         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12593         calls->o = (*env)->NewWeakGlobalRef(env, o);
12594         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
12595         CHECK(calls->handle_open_channel_meth != NULL);
12596         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
12597         CHECK(calls->handle_accept_channel_meth != NULL);
12598         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
12599         CHECK(calls->handle_funding_created_meth != NULL);
12600         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
12601         CHECK(calls->handle_funding_signed_meth != NULL);
12602         calls->handle_channel_ready_meth = (*env)->GetMethodID(env, c, "handle_channel_ready", "([BJ)V");
12603         CHECK(calls->handle_channel_ready_meth != NULL);
12604         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
12605         CHECK(calls->handle_shutdown_meth != NULL);
12606         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
12607         CHECK(calls->handle_closing_signed_meth != NULL);
12608         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
12609         CHECK(calls->handle_update_add_htlc_meth != NULL);
12610         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
12611         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
12612         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
12613         CHECK(calls->handle_update_fail_htlc_meth != NULL);
12614         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
12615         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
12616         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
12617         CHECK(calls->handle_commitment_signed_meth != NULL);
12618         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
12619         CHECK(calls->handle_revoke_and_ack_meth != NULL);
12620         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
12621         CHECK(calls->handle_update_fee_meth != NULL);
12622         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
12623         CHECK(calls->handle_announcement_signatures_meth != NULL);
12624         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
12625         CHECK(calls->peer_disconnected_meth != NULL);
12626         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
12627         CHECK(calls->peer_connected_meth != NULL);
12628         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
12629         CHECK(calls->handle_channel_reestablish_meth != NULL);
12630         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
12631         CHECK(calls->handle_channel_update_meth != NULL);
12632         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
12633         CHECK(calls->handle_error_meth != NULL);
12634
12635         LDKChannelMessageHandler ret = {
12636                 .this_arg = (void*) calls,
12637                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
12638                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
12639                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
12640                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
12641                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
12642                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
12643                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
12644                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
12645                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
12646                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
12647                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
12648                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
12649                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
12650                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
12651                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
12652                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
12653                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
12654                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
12655                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
12656                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
12657                 .free = LDKChannelMessageHandler_JCalls_free,
12658                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
12659         };
12660         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
12661         return ret;
12662 }
12663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12664         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
12665         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
12666         return (uint64_t)res_ptr;
12667 }
12668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
12669         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
12670         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
12671         DO_ASSERT((res_ptr & 1) == 0);
12672         return (int64_t)(res_ptr | 1);
12673 }
12674 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) {
12675         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12676         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12677         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12678         LDKPublicKey their_node_id_ref;
12679         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12680         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12681         LDKInitFeatures their_features_conv;
12682         their_features_conv.inner = (void*)(their_features & (~1));
12683         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
12684         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12685         their_features_conv = InitFeatures_clone(&their_features_conv);
12686         LDKOpenChannel msg_conv;
12687         msg_conv.inner = (void*)(msg & (~1));
12688         msg_conv.is_owned = false;
12689         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12690         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12691 }
12692
12693 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) {
12694         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12695         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12696         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12697         LDKPublicKey their_node_id_ref;
12698         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12699         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12700         LDKInitFeatures their_features_conv;
12701         their_features_conv.inner = (void*)(their_features & (~1));
12702         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
12703         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12704         their_features_conv = InitFeatures_clone(&their_features_conv);
12705         LDKAcceptChannel msg_conv;
12706         msg_conv.inner = (void*)(msg & (~1));
12707         msg_conv.is_owned = false;
12708         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12709         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12710 }
12711
12712 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) {
12713         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12714         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12715         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12716         LDKPublicKey their_node_id_ref;
12717         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12718         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12719         LDKFundingCreated msg_conv;
12720         msg_conv.inner = (void*)(msg & (~1));
12721         msg_conv.is_owned = false;
12722         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12723         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12724 }
12725
12726 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) {
12727         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12728         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12729         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12730         LDKPublicKey their_node_id_ref;
12731         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12732         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12733         LDKFundingSigned msg_conv;
12734         msg_conv.inner = (void*)(msg & (~1));
12735         msg_conv.is_owned = false;
12736         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12737         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12738 }
12739
12740 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) {
12741         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12742         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12743         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12744         LDKPublicKey their_node_id_ref;
12745         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12746         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12747         LDKChannelReady msg_conv;
12748         msg_conv.inner = (void*)(msg & (~1));
12749         msg_conv.is_owned = false;
12750         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12751         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12752 }
12753
12754 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) {
12755         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12756         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12757         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12758         LDKPublicKey their_node_id_ref;
12759         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12760         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12761         LDKInitFeatures their_features_conv;
12762         their_features_conv.inner = (void*)(their_features & (~1));
12763         their_features_conv.is_owned = false;
12764         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12765         LDKShutdown msg_conv;
12766         msg_conv.inner = (void*)(msg & (~1));
12767         msg_conv.is_owned = false;
12768         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12769         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
12770 }
12771
12772 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) {
12773         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12774         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12775         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12776         LDKPublicKey their_node_id_ref;
12777         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12778         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12779         LDKClosingSigned msg_conv;
12780         msg_conv.inner = (void*)(msg & (~1));
12781         msg_conv.is_owned = false;
12782         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12783         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12784 }
12785
12786 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) {
12787         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12788         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12789         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12790         LDKPublicKey their_node_id_ref;
12791         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12792         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12793         LDKUpdateAddHTLC msg_conv;
12794         msg_conv.inner = (void*)(msg & (~1));
12795         msg_conv.is_owned = false;
12796         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12797         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12798 }
12799
12800 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) {
12801         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12802         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12803         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12804         LDKPublicKey their_node_id_ref;
12805         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12806         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12807         LDKUpdateFulfillHTLC msg_conv;
12808         msg_conv.inner = (void*)(msg & (~1));
12809         msg_conv.is_owned = false;
12810         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12811         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12812 }
12813
12814 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) {
12815         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12816         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12817         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12818         LDKPublicKey their_node_id_ref;
12819         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12820         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12821         LDKUpdateFailHTLC msg_conv;
12822         msg_conv.inner = (void*)(msg & (~1));
12823         msg_conv.is_owned = false;
12824         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12825         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12826 }
12827
12828 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) {
12829         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12830         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12831         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12832         LDKPublicKey their_node_id_ref;
12833         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12834         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12835         LDKUpdateFailMalformedHTLC msg_conv;
12836         msg_conv.inner = (void*)(msg & (~1));
12837         msg_conv.is_owned = false;
12838         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12839         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12840 }
12841
12842 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) {
12843         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12844         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12845         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12846         LDKPublicKey their_node_id_ref;
12847         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12848         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12849         LDKCommitmentSigned msg_conv;
12850         msg_conv.inner = (void*)(msg & (~1));
12851         msg_conv.is_owned = false;
12852         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12853         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12854 }
12855
12856 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) {
12857         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12858         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12859         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12860         LDKPublicKey their_node_id_ref;
12861         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12862         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12863         LDKRevokeAndACK msg_conv;
12864         msg_conv.inner = (void*)(msg & (~1));
12865         msg_conv.is_owned = false;
12866         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12867         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12868 }
12869
12870 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) {
12871         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12872         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12873         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12874         LDKPublicKey their_node_id_ref;
12875         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12876         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12877         LDKUpdateFee msg_conv;
12878         msg_conv.inner = (void*)(msg & (~1));
12879         msg_conv.is_owned = false;
12880         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12881         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12882 }
12883
12884 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) {
12885         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12886         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12887         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12888         LDKPublicKey their_node_id_ref;
12889         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12890         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12891         LDKAnnouncementSignatures msg_conv;
12892         msg_conv.inner = (void*)(msg & (~1));
12893         msg_conv.is_owned = false;
12894         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12895         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12896 }
12897
12898 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) {
12899         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12900         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12901         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12902         LDKPublicKey their_node_id_ref;
12903         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12904         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12905         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
12906 }
12907
12908 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) {
12909         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12910         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12911         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12912         LDKPublicKey their_node_id_ref;
12913         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12914         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12915         LDKInit msg_conv;
12916         msg_conv.inner = (void*)(msg & (~1));
12917         msg_conv.is_owned = false;
12918         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12919         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12920 }
12921
12922 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) {
12923         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12924         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12925         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12926         LDKPublicKey their_node_id_ref;
12927         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12928         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12929         LDKChannelReestablish msg_conv;
12930         msg_conv.inner = (void*)(msg & (~1));
12931         msg_conv.is_owned = false;
12932         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12933         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12934 }
12935
12936 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) {
12937         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12938         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12939         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12940         LDKPublicKey their_node_id_ref;
12941         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12942         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12943         LDKChannelUpdate msg_conv;
12944         msg_conv.inner = (void*)(msg & (~1));
12945         msg_conv.is_owned = false;
12946         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12947         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12948 }
12949
12950 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) {
12951         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12952         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12953         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12954         LDKPublicKey their_node_id_ref;
12955         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12956         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12957         LDKErrorMessage msg_conv;
12958         msg_conv.inner = (void*)(msg & (~1));
12959         msg_conv.is_owned = false;
12960         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12961         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12962 }
12963
12964 typedef struct LDKRoutingMessageHandler_JCalls {
12965         atomic_size_t refcnt;
12966         JavaVM *vm;
12967         jweak o;
12968         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
12969         jmethodID handle_node_announcement_meth;
12970         jmethodID handle_channel_announcement_meth;
12971         jmethodID handle_channel_update_meth;
12972         jmethodID get_next_channel_announcements_meth;
12973         jmethodID get_next_node_announcements_meth;
12974         jmethodID peer_connected_meth;
12975         jmethodID handle_reply_channel_range_meth;
12976         jmethodID handle_reply_short_channel_ids_end_meth;
12977         jmethodID handle_query_channel_range_meth;
12978         jmethodID handle_query_short_channel_ids_meth;
12979 } LDKRoutingMessageHandler_JCalls;
12980 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
12981         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12982         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12983                 JNIEnv *env;
12984                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12985                 if (get_jenv_res == JNI_EDETACHED) {
12986                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12987                 } else {
12988                         DO_ASSERT(get_jenv_res == JNI_OK);
12989                 }
12990                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12991                 if (get_jenv_res == JNI_EDETACHED) {
12992                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12993                 }
12994                 FREE(j_calls);
12995         }
12996 }
12997 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
12998         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12999         JNIEnv *env;
13000         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13001         if (get_jenv_res == JNI_EDETACHED) {
13002                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13003         } else {
13004                 DO_ASSERT(get_jenv_res == JNI_OK);
13005         }
13006         LDKNodeAnnouncement msg_var = *msg;
13007         int64_t msg_ref = 0;
13008         msg_var = NodeAnnouncement_clone(&msg_var);
13009         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13010         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13011         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13012         msg_ref = (uintptr_t)msg_var.inner;
13013         if (msg_var.is_owned) {
13014                 msg_ref |= 1;
13015         }
13016         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13017         CHECK(obj != NULL);
13018         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
13019         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13020                 (*env)->ExceptionDescribe(env);
13021                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
13022         }
13023         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13024         CHECK_ACCESS(ret_ptr);
13025         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13026         FREE((void*)ret);
13027         if (get_jenv_res == JNI_EDETACHED) {
13028                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13029         }
13030         return ret_conv;
13031 }
13032 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
13033         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13034         JNIEnv *env;
13035         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13036         if (get_jenv_res == JNI_EDETACHED) {
13037                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13038         } else {
13039                 DO_ASSERT(get_jenv_res == JNI_OK);
13040         }
13041         LDKChannelAnnouncement msg_var = *msg;
13042         int64_t msg_ref = 0;
13043         msg_var = ChannelAnnouncement_clone(&msg_var);
13044         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13045         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13046         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13047         msg_ref = (uintptr_t)msg_var.inner;
13048         if (msg_var.is_owned) {
13049                 msg_ref |= 1;
13050         }
13051         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13052         CHECK(obj != NULL);
13053         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
13054         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13055                 (*env)->ExceptionDescribe(env);
13056                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
13057         }
13058         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13059         CHECK_ACCESS(ret_ptr);
13060         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13061         FREE((void*)ret);
13062         if (get_jenv_res == JNI_EDETACHED) {
13063                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13064         }
13065         return ret_conv;
13066 }
13067 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
13068         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13069         JNIEnv *env;
13070         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13071         if (get_jenv_res == JNI_EDETACHED) {
13072                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13073         } else {
13074                 DO_ASSERT(get_jenv_res == JNI_OK);
13075         }
13076         LDKChannelUpdate msg_var = *msg;
13077         int64_t msg_ref = 0;
13078         msg_var = ChannelUpdate_clone(&msg_var);
13079         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13080         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13081         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13082         msg_ref = (uintptr_t)msg_var.inner;
13083         if (msg_var.is_owned) {
13084                 msg_ref |= 1;
13085         }
13086         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13087         CHECK(obj != NULL);
13088         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
13089         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13090                 (*env)->ExceptionDescribe(env);
13091                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
13092         }
13093         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13094         CHECK_ACCESS(ret_ptr);
13095         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13096         FREE((void*)ret);
13097         if (get_jenv_res == JNI_EDETACHED) {
13098                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13099         }
13100         return ret_conv;
13101 }
13102 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
13103         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13104         JNIEnv *env;
13105         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13106         if (get_jenv_res == JNI_EDETACHED) {
13107                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13108         } else {
13109                 DO_ASSERT(get_jenv_res == JNI_OK);
13110         }
13111         int64_t starting_point_conv = starting_point;
13112         int8_t batch_amount_conv = batch_amount;
13113         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13114         CHECK(obj != NULL);
13115         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point_conv, batch_amount_conv);
13116         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13117                 (*env)->ExceptionDescribe(env);
13118                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
13119         }
13120         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
13121         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13122         if (ret_constr.datalen > 0)
13123                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
13124         else
13125                 ret_constr.data = NULL;
13126         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13127         for (size_t h = 0; h < ret_constr.datalen; h++) {
13128                 int64_t ret_conv_59 = ret_vals[h];
13129                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
13130                 CHECK_ACCESS(ret_conv_59_ptr);
13131                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
13132                 FREE((void*)ret_conv_59);
13133                 ret_constr.data[h] = ret_conv_59_conv;
13134         }
13135         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13136         if (get_jenv_res == JNI_EDETACHED) {
13137                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13138         }
13139         return ret_constr;
13140 }
13141 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
13142         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13143         JNIEnv *env;
13144         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13145         if (get_jenv_res == JNI_EDETACHED) {
13146                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13147         } else {
13148                 DO_ASSERT(get_jenv_res == JNI_OK);
13149         }
13150         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
13151         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
13152         int8_t batch_amount_conv = batch_amount;
13153         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13154         CHECK(obj != NULL);
13155         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount_conv);
13156         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13157                 (*env)->ExceptionDescribe(env);
13158                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
13159         }
13160         LDKCVec_NodeAnnouncementZ ret_constr;
13161         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13162         if (ret_constr.datalen > 0)
13163                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
13164         else
13165                 ret_constr.data = NULL;
13166         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13167         for (size_t s = 0; s < ret_constr.datalen; s++) {
13168                 int64_t ret_conv_18 = ret_vals[s];
13169                 LDKNodeAnnouncement ret_conv_18_conv;
13170                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
13171                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
13172                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
13173                 ret_constr.data[s] = ret_conv_18_conv;
13174         }
13175         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13176         if (get_jenv_res == JNI_EDETACHED) {
13177                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13178         }
13179         return ret_constr;
13180 }
13181 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
13182         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13183         JNIEnv *env;
13184         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13185         if (get_jenv_res == JNI_EDETACHED) {
13186                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13187         } else {
13188                 DO_ASSERT(get_jenv_res == JNI_OK);
13189         }
13190         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13191         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13192         LDKInit init_var = *init;
13193         int64_t init_ref = 0;
13194         init_var = Init_clone(&init_var);
13195         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13196         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13197         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
13198         init_ref = (uintptr_t)init_var.inner;
13199         if (init_var.is_owned) {
13200                 init_ref |= 1;
13201         }
13202         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13203         CHECK(obj != NULL);
13204         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
13205         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13206                 (*env)->ExceptionDescribe(env);
13207                 (*env)->FatalError(env, "A call to peer_connected in LDKRoutingMessageHandler from rust threw an exception.");
13208         }
13209         if (get_jenv_res == JNI_EDETACHED) {
13210                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13211         }
13212 }
13213 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
13214         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13215         JNIEnv *env;
13216         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13217         if (get_jenv_res == JNI_EDETACHED) {
13218                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13219         } else {
13220                 DO_ASSERT(get_jenv_res == JNI_OK);
13221         }
13222         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13223         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13224         LDKReplyChannelRange msg_var = msg;
13225         int64_t msg_ref = 0;
13226         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13227         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13228         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13229         msg_ref = (uintptr_t)msg_var.inner;
13230         if (msg_var.is_owned) {
13231                 msg_ref |= 1;
13232         }
13233         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13234         CHECK(obj != NULL);
13235         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
13236         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13237                 (*env)->ExceptionDescribe(env);
13238                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
13239         }
13240         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13241         CHECK_ACCESS(ret_ptr);
13242         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13243         FREE((void*)ret);
13244         if (get_jenv_res == JNI_EDETACHED) {
13245                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13246         }
13247         return ret_conv;
13248 }
13249 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
13250         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13251         JNIEnv *env;
13252         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13253         if (get_jenv_res == JNI_EDETACHED) {
13254                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13255         } else {
13256                 DO_ASSERT(get_jenv_res == JNI_OK);
13257         }
13258         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13259         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13260         LDKReplyShortChannelIdsEnd msg_var = msg;
13261         int64_t msg_ref = 0;
13262         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13263         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13264         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13265         msg_ref = (uintptr_t)msg_var.inner;
13266         if (msg_var.is_owned) {
13267                 msg_ref |= 1;
13268         }
13269         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13270         CHECK(obj != NULL);
13271         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
13272         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13273                 (*env)->ExceptionDescribe(env);
13274                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
13275         }
13276         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13277         CHECK_ACCESS(ret_ptr);
13278         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13279         FREE((void*)ret);
13280         if (get_jenv_res == JNI_EDETACHED) {
13281                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13282         }
13283         return ret_conv;
13284 }
13285 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
13286         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13287         JNIEnv *env;
13288         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13289         if (get_jenv_res == JNI_EDETACHED) {
13290                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13291         } else {
13292                 DO_ASSERT(get_jenv_res == JNI_OK);
13293         }
13294         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13295         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13296         LDKQueryChannelRange msg_var = msg;
13297         int64_t msg_ref = 0;
13298         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13299         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13300         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13301         msg_ref = (uintptr_t)msg_var.inner;
13302         if (msg_var.is_owned) {
13303                 msg_ref |= 1;
13304         }
13305         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13306         CHECK(obj != NULL);
13307         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
13308         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13309                 (*env)->ExceptionDescribe(env);
13310                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
13311         }
13312         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13313         CHECK_ACCESS(ret_ptr);
13314         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13315         FREE((void*)ret);
13316         if (get_jenv_res == JNI_EDETACHED) {
13317                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13318         }
13319         return ret_conv;
13320 }
13321 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
13322         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13323         JNIEnv *env;
13324         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13325         if (get_jenv_res == JNI_EDETACHED) {
13326                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13327         } else {
13328                 DO_ASSERT(get_jenv_res == JNI_OK);
13329         }
13330         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13331         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13332         LDKQueryShortChannelIds msg_var = msg;
13333         int64_t msg_ref = 0;
13334         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13335         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13336         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13337         msg_ref = (uintptr_t)msg_var.inner;
13338         if (msg_var.is_owned) {
13339                 msg_ref |= 1;
13340         }
13341         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13342         CHECK(obj != NULL);
13343         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
13344         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13345                 (*env)->ExceptionDescribe(env);
13346                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
13347         }
13348         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13349         CHECK_ACCESS(ret_ptr);
13350         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13351         FREE((void*)ret);
13352         if (get_jenv_res == JNI_EDETACHED) {
13353                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13354         }
13355         return ret_conv;
13356 }
13357 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
13358         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
13359         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13360         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
13361 }
13362 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13363         jclass c = (*env)->GetObjectClass(env, o);
13364         CHECK(c != NULL);
13365         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
13366         atomic_init(&calls->refcnt, 1);
13367         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13368         calls->o = (*env)->NewWeakGlobalRef(env, o);
13369         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
13370         CHECK(calls->handle_node_announcement_meth != NULL);
13371         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
13372         CHECK(calls->handle_channel_announcement_meth != NULL);
13373         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
13374         CHECK(calls->handle_channel_update_meth != NULL);
13375         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
13376         CHECK(calls->get_next_channel_announcements_meth != NULL);
13377         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
13378         CHECK(calls->get_next_node_announcements_meth != NULL);
13379         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
13380         CHECK(calls->peer_connected_meth != NULL);
13381         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
13382         CHECK(calls->handle_reply_channel_range_meth != NULL);
13383         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
13384         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
13385         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
13386         CHECK(calls->handle_query_channel_range_meth != NULL);
13387         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
13388         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
13389
13390         LDKRoutingMessageHandler ret = {
13391                 .this_arg = (void*) calls,
13392                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
13393                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
13394                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
13395                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
13396                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
13397                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
13398                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
13399                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
13400                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
13401                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
13402                 .free = LDKRoutingMessageHandler_JCalls_free,
13403                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
13404         };
13405         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
13406         return ret;
13407 }
13408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13409         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
13410         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
13411         return (uint64_t)res_ptr;
13412 }
13413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
13414         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
13415         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
13416         DO_ASSERT((res_ptr & 1) == 0);
13417         return (int64_t)(res_ptr | 1);
13418 }
13419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13420         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13421         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13422         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13423         LDKNodeAnnouncement msg_conv;
13424         msg_conv.inner = (void*)(msg & (~1));
13425         msg_conv.is_owned = false;
13426         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13427         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13428         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
13429         return (int64_t)ret_conv;
13430 }
13431
13432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13433         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13434         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13435         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13436         LDKChannelAnnouncement msg_conv;
13437         msg_conv.inner = (void*)(msg & (~1));
13438         msg_conv.is_owned = false;
13439         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13440         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13441         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
13442         return (int64_t)ret_conv;
13443 }
13444
13445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13446         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13447         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13448         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13449         LDKChannelUpdate msg_conv;
13450         msg_conv.inner = (void*)(msg & (~1));
13451         msg_conv.is_owned = false;
13452         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13453         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13454         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
13455         return (int64_t)ret_conv;
13456 }
13457
13458 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) {
13459         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13460         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13461         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13462         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
13463         int64_tArray ret_arr = NULL;
13464         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13465         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13466         for (size_t h = 0; h < ret_var.datalen; h++) {
13467                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13468                 *ret_conv_59_conv = ret_var.data[h];
13469                 ret_arr_ptr[h] = ((int64_t)ret_conv_59_conv);
13470         }
13471         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13472         FREE(ret_var.data);
13473         return ret_arr;
13474 }
13475
13476 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) {
13477         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13478         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13479         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13480         LDKPublicKey starting_point_ref;
13481         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
13482         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
13483         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
13484         int64_tArray ret_arr = NULL;
13485         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13486         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13487         for (size_t s = 0; s < ret_var.datalen; s++) {
13488                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
13489                 int64_t ret_conv_18_ref = 0;
13490                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13491                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13492                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
13493                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
13494                 if (ret_conv_18_var.is_owned) {
13495                         ret_conv_18_ref |= 1;
13496                 }
13497                 ret_arr_ptr[s] = ret_conv_18_ref;
13498         }
13499         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13500         FREE(ret_var.data);
13501         return ret_arr;
13502 }
13503
13504 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) {
13505         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13506         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13507         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13508         LDKPublicKey their_node_id_ref;
13509         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13510         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13511         LDKInit init_conv;
13512         init_conv.inner = (void*)(init & (~1));
13513         init_conv.is_owned = false;
13514         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
13515         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
13516 }
13517
13518 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) {
13519         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13520         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13521         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13522         LDKPublicKey their_node_id_ref;
13523         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13524         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13525         LDKReplyChannelRange msg_conv;
13526         msg_conv.inner = (void*)(msg & (~1));
13527         msg_conv.is_owned = (msg & 1) || (msg == 0);
13528         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13529         msg_conv = ReplyChannelRange_clone(&msg_conv);
13530         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13531         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13532         return (int64_t)ret_conv;
13533 }
13534
13535 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) {
13536         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13537         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13538         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13539         LDKPublicKey their_node_id_ref;
13540         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13541         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13542         LDKReplyShortChannelIdsEnd msg_conv;
13543         msg_conv.inner = (void*)(msg & (~1));
13544         msg_conv.is_owned = (msg & 1) || (msg == 0);
13545         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13546         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
13547         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13548         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13549         return (int64_t)ret_conv;
13550 }
13551
13552 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) {
13553         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13554         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13555         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13556         LDKPublicKey their_node_id_ref;
13557         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13558         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13559         LDKQueryChannelRange msg_conv;
13560         msg_conv.inner = (void*)(msg & (~1));
13561         msg_conv.is_owned = (msg & 1) || (msg == 0);
13562         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13563         msg_conv = QueryChannelRange_clone(&msg_conv);
13564         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13565         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13566         return (int64_t)ret_conv;
13567 }
13568
13569 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) {
13570         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13571         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13572         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13573         LDKPublicKey their_node_id_ref;
13574         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13575         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13576         LDKQueryShortChannelIds msg_conv;
13577         msg_conv.inner = (void*)(msg & (~1));
13578         msg_conv.is_owned = (msg & 1) || (msg == 0);
13579         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13580         msg_conv = QueryShortChannelIds_clone(&msg_conv);
13581         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13582         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13583         return (int64_t)ret_conv;
13584 }
13585
13586 typedef struct LDKCustomMessageReader_JCalls {
13587         atomic_size_t refcnt;
13588         JavaVM *vm;
13589         jweak o;
13590         jmethodID read_meth;
13591 } LDKCustomMessageReader_JCalls;
13592 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
13593         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
13594         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13595                 JNIEnv *env;
13596                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13597                 if (get_jenv_res == JNI_EDETACHED) {
13598                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13599                 } else {
13600                         DO_ASSERT(get_jenv_res == JNI_OK);
13601                 }
13602                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13603                 if (get_jenv_res == JNI_EDETACHED) {
13604                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13605                 }
13606                 FREE(j_calls);
13607         }
13608 }
13609 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
13610         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
13611         JNIEnv *env;
13612         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13613         if (get_jenv_res == JNI_EDETACHED) {
13614                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13615         } else {
13616                 DO_ASSERT(get_jenv_res == JNI_OK);
13617         }
13618         int16_t message_type_conv = message_type;
13619         LDKu8slice buffer_var = buffer;
13620         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
13621         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
13622         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13623         CHECK(obj != NULL);
13624         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type_conv, buffer_arr);
13625         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13626                 (*env)->ExceptionDescribe(env);
13627                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
13628         }
13629         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13630         CHECK_ACCESS(ret_ptr);
13631         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
13632         FREE((void*)ret);
13633         if (get_jenv_res == JNI_EDETACHED) {
13634                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13635         }
13636         return ret_conv;
13637 }
13638 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
13639         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
13640         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13641 }
13642 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
13643         jclass c = (*env)->GetObjectClass(env, o);
13644         CHECK(c != NULL);
13645         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
13646         atomic_init(&calls->refcnt, 1);
13647         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13648         calls->o = (*env)->NewWeakGlobalRef(env, o);
13649         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
13650         CHECK(calls->read_meth != NULL);
13651
13652         LDKCustomMessageReader ret = {
13653                 .this_arg = (void*) calls,
13654                 .read = read_LDKCustomMessageReader_jcall,
13655                 .free = LDKCustomMessageReader_JCalls_free,
13656         };
13657         return ret;
13658 }
13659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
13660         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
13661         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
13662         return (uint64_t)res_ptr;
13663 }
13664 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) {
13665         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13666         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13667         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
13668         LDKu8slice buffer_ref;
13669         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
13670         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
13671         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
13672         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
13673         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
13674         return (int64_t)ret_conv;
13675 }
13676
13677 typedef struct LDKCustomMessageHandler_JCalls {
13678         atomic_size_t refcnt;
13679         JavaVM *vm;
13680         jweak o;
13681         LDKCustomMessageReader_JCalls* CustomMessageReader;
13682         jmethodID handle_custom_message_meth;
13683         jmethodID get_and_clear_pending_msg_meth;
13684 } LDKCustomMessageHandler_JCalls;
13685 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
13686         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13687         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13688                 JNIEnv *env;
13689                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13690                 if (get_jenv_res == JNI_EDETACHED) {
13691                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13692                 } else {
13693                         DO_ASSERT(get_jenv_res == JNI_OK);
13694                 }
13695                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13696                 if (get_jenv_res == JNI_EDETACHED) {
13697                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13698                 }
13699                 FREE(j_calls);
13700         }
13701 }
13702 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
13703         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13704         JNIEnv *env;
13705         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13706         if (get_jenv_res == JNI_EDETACHED) {
13707                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13708         } else {
13709                 DO_ASSERT(get_jenv_res == JNI_OK);
13710         }
13711         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
13712         *msg_ret = msg;
13713         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
13714         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
13715         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13716         CHECK(obj != NULL);
13717         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (int64_t)msg_ret, sender_node_id_arr);
13718         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13719                 (*env)->ExceptionDescribe(env);
13720                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
13721         }
13722         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13723         CHECK_ACCESS(ret_ptr);
13724         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13725         FREE((void*)ret);
13726         if (get_jenv_res == JNI_EDETACHED) {
13727                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13728         }
13729         return ret_conv;
13730 }
13731 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
13732         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13733         JNIEnv *env;
13734         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13735         if (get_jenv_res == JNI_EDETACHED) {
13736                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13737         } else {
13738                 DO_ASSERT(get_jenv_res == JNI_OK);
13739         }
13740         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13741         CHECK(obj != NULL);
13742         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
13743         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13744                 (*env)->ExceptionDescribe(env);
13745                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
13746         }
13747         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
13748         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13749         if (ret_constr.datalen > 0)
13750                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
13751         else
13752                 ret_constr.data = NULL;
13753         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13754         for (size_t z = 0; z < ret_constr.datalen; z++) {
13755                 int64_t ret_conv_25 = ret_vals[z];
13756                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
13757                 CHECK_ACCESS(ret_conv_25_ptr);
13758                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
13759                 FREE((void*)ret_conv_25);
13760                 ret_constr.data[z] = ret_conv_25_conv;
13761         }
13762         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13763         if (get_jenv_res == JNI_EDETACHED) {
13764                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13765         }
13766         return ret_constr;
13767 }
13768 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
13769         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
13770         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13771         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
13772 }
13773 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
13774         jclass c = (*env)->GetObjectClass(env, o);
13775         CHECK(c != NULL);
13776         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
13777         atomic_init(&calls->refcnt, 1);
13778         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13779         calls->o = (*env)->NewWeakGlobalRef(env, o);
13780         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
13781         CHECK(calls->handle_custom_message_meth != NULL);
13782         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
13783         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
13784
13785         LDKCustomMessageHandler ret = {
13786                 .this_arg = (void*) calls,
13787                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
13788                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
13789                 .free = LDKCustomMessageHandler_JCalls_free,
13790                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
13791         };
13792         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
13793         return ret;
13794 }
13795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
13796         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
13797         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
13798         return (uint64_t)res_ptr;
13799 }
13800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
13801         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
13802         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
13803         DO_ASSERT((res_ptr & 1) == 0);
13804         return (int64_t)(res_ptr | 1);
13805 }
13806 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) {
13807         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13808         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13809         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
13810         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
13811         CHECK_ACCESS(msg_ptr);
13812         LDKType msg_conv = *(LDKType*)(msg_ptr);
13813         if (msg_conv.free == LDKType_JCalls_free) {
13814                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13815                 LDKType_JCalls_cloned(&msg_conv);
13816         }
13817         LDKPublicKey sender_node_id_ref;
13818         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
13819         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
13820         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13821         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
13822         return (int64_t)ret_conv;
13823 }
13824
13825 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
13826         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13827         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13828         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
13829         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
13830         int64_tArray ret_arr = NULL;
13831         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13832         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13833         for (size_t z = 0; z < ret_var.datalen; z++) {
13834                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13835                 *ret_conv_25_conv = ret_var.data[z];
13836                 ret_arr_ptr[z] = ((int64_t)ret_conv_25_conv);
13837         }
13838         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13839         FREE(ret_var.data);
13840         return ret_arr;
13841 }
13842
13843 typedef struct LDKSocketDescriptor_JCalls {
13844         atomic_size_t refcnt;
13845         JavaVM *vm;
13846         jweak o;
13847         jmethodID send_data_meth;
13848         jmethodID disconnect_socket_meth;
13849         jmethodID eq_meth;
13850         jmethodID hash_meth;
13851 } LDKSocketDescriptor_JCalls;
13852 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
13853         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13854         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13855                 JNIEnv *env;
13856                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13857                 if (get_jenv_res == JNI_EDETACHED) {
13858                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13859                 } else {
13860                         DO_ASSERT(get_jenv_res == JNI_OK);
13861                 }
13862                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13863                 if (get_jenv_res == JNI_EDETACHED) {
13864                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13865                 }
13866                 FREE(j_calls);
13867         }
13868 }
13869 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
13870         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13871         JNIEnv *env;
13872         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13873         if (get_jenv_res == JNI_EDETACHED) {
13874                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13875         } else {
13876                 DO_ASSERT(get_jenv_res == JNI_OK);
13877         }
13878         LDKu8slice data_var = data;
13879         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
13880         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
13881         jboolean resume_read_conv = resume_read;
13882         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13883         CHECK(obj != NULL);
13884         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read_conv);
13885         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13886                 (*env)->ExceptionDescribe(env);
13887                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
13888         }
13889         if (get_jenv_res == JNI_EDETACHED) {
13890                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13891         }
13892         return ret;
13893 }
13894 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
13895         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13896         JNIEnv *env;
13897         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13898         if (get_jenv_res == JNI_EDETACHED) {
13899                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13900         } else {
13901                 DO_ASSERT(get_jenv_res == JNI_OK);
13902         }
13903         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13904         CHECK(obj != NULL);
13905         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
13906         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13907                 (*env)->ExceptionDescribe(env);
13908                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
13909         }
13910         if (get_jenv_res == JNI_EDETACHED) {
13911                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13912         }
13913 }
13914 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
13915         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13916         JNIEnv *env;
13917         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13918         if (get_jenv_res == JNI_EDETACHED) {
13919                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13920         } else {
13921                 DO_ASSERT(get_jenv_res == JNI_OK);
13922         }
13923         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
13924         *other_arg_clone = SocketDescriptor_clone(other_arg);
13925         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13926         CHECK(obj != NULL);
13927         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (int64_t)other_arg_clone);
13928         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13929                 (*env)->ExceptionDescribe(env);
13930                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
13931         }
13932         if (get_jenv_res == JNI_EDETACHED) {
13933                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13934         }
13935         return ret;
13936 }
13937 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
13938         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13939         JNIEnv *env;
13940         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13941         if (get_jenv_res == JNI_EDETACHED) {
13942                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13943         } else {
13944                 DO_ASSERT(get_jenv_res == JNI_OK);
13945         }
13946         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13947         CHECK(obj != NULL);
13948         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
13949         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13950                 (*env)->ExceptionDescribe(env);
13951                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
13952         }
13953         if (get_jenv_res == JNI_EDETACHED) {
13954                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13955         }
13956         return ret;
13957 }
13958 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
13959         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
13960         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13961 }
13962 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
13963         jclass c = (*env)->GetObjectClass(env, o);
13964         CHECK(c != NULL);
13965         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
13966         atomic_init(&calls->refcnt, 1);
13967         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13968         calls->o = (*env)->NewWeakGlobalRef(env, o);
13969         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
13970         CHECK(calls->send_data_meth != NULL);
13971         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
13972         CHECK(calls->disconnect_socket_meth != NULL);
13973         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
13974         CHECK(calls->eq_meth != NULL);
13975         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
13976         CHECK(calls->hash_meth != NULL);
13977
13978         LDKSocketDescriptor ret = {
13979                 .this_arg = (void*) calls,
13980                 .send_data = send_data_LDKSocketDescriptor_jcall,
13981                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
13982                 .eq = eq_LDKSocketDescriptor_jcall,
13983                 .hash = hash_LDKSocketDescriptor_jcall,
13984                 .cloned = LDKSocketDescriptor_JCalls_cloned,
13985                 .free = LDKSocketDescriptor_JCalls_free,
13986         };
13987         return ret;
13988 }
13989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
13990         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
13991         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
13992         return (uint64_t)res_ptr;
13993 }
13994 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) {
13995         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13996         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13997         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
13998         LDKu8slice data_ref;
13999         data_ref.datalen = (*env)->GetArrayLength(env, data);
14000         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
14001         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
14002         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
14003         return ret_conv;
14004 }
14005
14006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
14007         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14008         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14009         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14010         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
14011 }
14012
14013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
14014         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14015         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14016         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14017         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
14018         return ret_conv;
14019 }
14020
14021 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
14022 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
14023 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
14024 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
14025 static jclass LDKEffectiveCapacity_Total_class = NULL;
14026 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
14027 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
14028 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
14029 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
14030 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
14031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
14032         LDKEffectiveCapacity_ExactLiquidity_class =
14033                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
14034         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
14035         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
14036         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
14037         LDKEffectiveCapacity_MaximumHTLC_class =
14038                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
14039         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
14040         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
14041         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
14042         LDKEffectiveCapacity_Total_class =
14043                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
14044         CHECK(LDKEffectiveCapacity_Total_class != NULL);
14045         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(JJ)V");
14046         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
14047         LDKEffectiveCapacity_Infinite_class =
14048                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
14049         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
14050         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
14051         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
14052         LDKEffectiveCapacity_Unknown_class =
14053                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
14054         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
14055         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
14056         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
14057 }
14058 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14059         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
14060         switch(obj->tag) {
14061                 case LDKEffectiveCapacity_ExactLiquidity: {
14062                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
14063                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, liquidity_msat_conv);
14064                 }
14065                 case LDKEffectiveCapacity_MaximumHTLC: {
14066                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
14067                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, amount_msat_conv);
14068                 }
14069                 case LDKEffectiveCapacity_Total: {
14070                         int64_t capacity_msat_conv = obj->total.capacity_msat;
14071                         int64_t htlc_maximum_msat_ref = ((uintptr_t)&obj->total.htlc_maximum_msat) | 1;
14072                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, capacity_msat_conv, htlc_maximum_msat_ref);
14073                 }
14074                 case LDKEffectiveCapacity_Infinite: {
14075                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
14076                 }
14077                 case LDKEffectiveCapacity_Unknown: {
14078                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
14079                 }
14080                 default: abort();
14081         }
14082 }
14083 typedef struct LDKLockableScore_JCalls {
14084         atomic_size_t refcnt;
14085         JavaVM *vm;
14086         jweak o;
14087         jmethodID lock_meth;
14088 } LDKLockableScore_JCalls;
14089 static void LDKLockableScore_JCalls_free(void* this_arg) {
14090         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
14091         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14092                 JNIEnv *env;
14093                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14094                 if (get_jenv_res == JNI_EDETACHED) {
14095                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14096                 } else {
14097                         DO_ASSERT(get_jenv_res == JNI_OK);
14098                 }
14099                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14100                 if (get_jenv_res == JNI_EDETACHED) {
14101                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14102                 }
14103                 FREE(j_calls);
14104         }
14105 }
14106 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
14107         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
14108         JNIEnv *env;
14109         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14110         if (get_jenv_res == JNI_EDETACHED) {
14111                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14112         } else {
14113                 DO_ASSERT(get_jenv_res == JNI_OK);
14114         }
14115         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14116         CHECK(obj != NULL);
14117         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
14118         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14119                 (*env)->ExceptionDescribe(env);
14120                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
14121         }
14122         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14123         CHECK_ACCESS(ret_ptr);
14124         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
14125         if (ret_conv.free == LDKScore_JCalls_free) {
14126                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14127                 LDKScore_JCalls_cloned(&ret_conv);
14128         }// WARNING: we may need a move here but no clone is available for LDKScore
14129         
14130         if (get_jenv_res == JNI_EDETACHED) {
14131                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14132         }
14133         return ret_conv;
14134 }
14135 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
14136         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
14137         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14138 }
14139 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
14140         jclass c = (*env)->GetObjectClass(env, o);
14141         CHECK(c != NULL);
14142         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
14143         atomic_init(&calls->refcnt, 1);
14144         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14145         calls->o = (*env)->NewWeakGlobalRef(env, o);
14146         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
14147         CHECK(calls->lock_meth != NULL);
14148
14149         LDKLockableScore ret = {
14150                 .this_arg = (void*) calls,
14151                 .lock = lock_LDKLockableScore_jcall,
14152                 .free = LDKLockableScore_JCalls_free,
14153         };
14154         return ret;
14155 }
14156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
14157         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
14158         *res_ptr = LDKLockableScore_init(env, clz, o);
14159         return (uint64_t)res_ptr;
14160 }
14161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
14162         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14163         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14164         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
14165         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
14166         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
14167         return (int64_t)ret_ret;
14168 }
14169
14170 static jclass LDKGossipSync_P2P_class = NULL;
14171 static jmethodID LDKGossipSync_P2P_meth = NULL;
14172 static jclass LDKGossipSync_Rapid_class = NULL;
14173 static jmethodID LDKGossipSync_Rapid_meth = NULL;
14174 static jclass LDKGossipSync_None_class = NULL;
14175 static jmethodID LDKGossipSync_None_meth = NULL;
14176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGossipSync_init (JNIEnv *env, jclass clz) {
14177         LDKGossipSync_P2P_class =
14178                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$P2P"));
14179         CHECK(LDKGossipSync_P2P_class != NULL);
14180         LDKGossipSync_P2P_meth = (*env)->GetMethodID(env, LDKGossipSync_P2P_class, "<init>", "(J)V");
14181         CHECK(LDKGossipSync_P2P_meth != NULL);
14182         LDKGossipSync_Rapid_class =
14183                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$Rapid"));
14184         CHECK(LDKGossipSync_Rapid_class != NULL);
14185         LDKGossipSync_Rapid_meth = (*env)->GetMethodID(env, LDKGossipSync_Rapid_class, "<init>", "(J)V");
14186         CHECK(LDKGossipSync_Rapid_meth != NULL);
14187         LDKGossipSync_None_class =
14188                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$None"));
14189         CHECK(LDKGossipSync_None_class != NULL);
14190         LDKGossipSync_None_meth = (*env)->GetMethodID(env, LDKGossipSync_None_class, "<init>", "()V");
14191         CHECK(LDKGossipSync_None_meth != NULL);
14192 }
14193 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGossipSync_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14194         LDKGossipSync *obj = (LDKGossipSync*)(ptr & ~1);
14195         switch(obj->tag) {
14196                 case LDKGossipSync_P2P: {
14197                         LDKP2PGossipSync p2p_var = obj->p2p;
14198                         int64_t p2p_ref = 0;
14199                         CHECK((((uintptr_t)p2p_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14200                         CHECK((((uintptr_t)&p2p_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14201                         CHECK_INNER_FIELD_ACCESS_OR_NULL(p2p_var);
14202                         p2p_ref = (uintptr_t)p2p_var.inner & ~1;
14203                         return (*env)->NewObject(env, LDKGossipSync_P2P_class, LDKGossipSync_P2P_meth, p2p_ref);
14204                 }
14205                 case LDKGossipSync_Rapid: {
14206                         LDKRapidGossipSync rapid_var = obj->rapid;
14207                         int64_t rapid_ref = 0;
14208                         CHECK((((uintptr_t)rapid_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14209                         CHECK((((uintptr_t)&rapid_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14210                         CHECK_INNER_FIELD_ACCESS_OR_NULL(rapid_var);
14211                         rapid_ref = (uintptr_t)rapid_var.inner & ~1;
14212                         return (*env)->NewObject(env, LDKGossipSync_Rapid_class, LDKGossipSync_Rapid_meth, rapid_ref);
14213                 }
14214                 case LDKGossipSync_None: {
14215                         return (*env)->NewObject(env, LDKGossipSync_None_class, LDKGossipSync_None_meth);
14216                 }
14217                 default: abort();
14218         }
14219 }
14220 static jclass LDKFallback_SegWitProgram_class = NULL;
14221 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
14222 static jclass LDKFallback_PubKeyHash_class = NULL;
14223 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
14224 static jclass LDKFallback_ScriptHash_class = NULL;
14225 static jmethodID LDKFallback_ScriptHash_meth = NULL;
14226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
14227         LDKFallback_SegWitProgram_class =
14228                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
14229         CHECK(LDKFallback_SegWitProgram_class != NULL);
14230         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
14231         CHECK(LDKFallback_SegWitProgram_meth != NULL);
14232         LDKFallback_PubKeyHash_class =
14233                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
14234         CHECK(LDKFallback_PubKeyHash_class != NULL);
14235         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
14236         CHECK(LDKFallback_PubKeyHash_meth != NULL);
14237         LDKFallback_ScriptHash_class =
14238                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
14239         CHECK(LDKFallback_ScriptHash_class != NULL);
14240         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
14241         CHECK(LDKFallback_ScriptHash_meth != NULL);
14242 }
14243 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14244         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
14245         switch(obj->tag) {
14246                 case LDKFallback_SegWitProgram: {
14247                         uint8_t version_val = obj->seg_wit_program.version._0;
14248                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
14249                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
14250                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
14251                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
14252                 }
14253                 case LDKFallback_PubKeyHash: {
14254                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
14255                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
14256                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
14257                 }
14258                 case LDKFallback_ScriptHash: {
14259                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
14260                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
14261                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
14262                 }
14263                 default: abort();
14264         }
14265 }
14266 typedef struct LDKPayer_JCalls {
14267         atomic_size_t refcnt;
14268         JavaVM *vm;
14269         jweak o;
14270         jmethodID node_id_meth;
14271         jmethodID first_hops_meth;
14272         jmethodID send_payment_meth;
14273         jmethodID send_spontaneous_payment_meth;
14274         jmethodID retry_payment_meth;
14275         jmethodID abandon_payment_meth;
14276 } LDKPayer_JCalls;
14277 static void LDKPayer_JCalls_free(void* this_arg) {
14278         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14279         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14280                 JNIEnv *env;
14281                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14282                 if (get_jenv_res == JNI_EDETACHED) {
14283                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14284                 } else {
14285                         DO_ASSERT(get_jenv_res == JNI_OK);
14286                 }
14287                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14288                 if (get_jenv_res == JNI_EDETACHED) {
14289                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14290                 }
14291                 FREE(j_calls);
14292         }
14293 }
14294 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
14295         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14296         JNIEnv *env;
14297         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14298         if (get_jenv_res == JNI_EDETACHED) {
14299                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14300         } else {
14301                 DO_ASSERT(get_jenv_res == JNI_OK);
14302         }
14303         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14304         CHECK(obj != NULL);
14305         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
14306         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14307                 (*env)->ExceptionDescribe(env);
14308                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
14309         }
14310         LDKPublicKey ret_ref;
14311         CHECK((*env)->GetArrayLength(env, ret) == 33);
14312         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
14313         if (get_jenv_res == JNI_EDETACHED) {
14314                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14315         }
14316         return ret_ref;
14317 }
14318 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
14319         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14320         JNIEnv *env;
14321         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14322         if (get_jenv_res == JNI_EDETACHED) {
14323                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14324         } else {
14325                 DO_ASSERT(get_jenv_res == JNI_OK);
14326         }
14327         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14328         CHECK(obj != NULL);
14329         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
14330         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14331                 (*env)->ExceptionDescribe(env);
14332                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
14333         }
14334         LDKCVec_ChannelDetailsZ ret_constr;
14335         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
14336         if (ret_constr.datalen > 0)
14337                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14338         else
14339                 ret_constr.data = NULL;
14340         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
14341         for (size_t q = 0; q < ret_constr.datalen; q++) {
14342                 int64_t ret_conv_16 = ret_vals[q];
14343                 LDKChannelDetails ret_conv_16_conv;
14344                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
14345                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
14346                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
14347                 ret_constr.data[q] = ret_conv_16_conv;
14348         }
14349         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
14350         if (get_jenv_res == JNI_EDETACHED) {
14351                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14352         }
14353         return ret_constr;
14354 }
14355 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
14356         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14357         JNIEnv *env;
14358         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14359         if (get_jenv_res == JNI_EDETACHED) {
14360                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14361         } else {
14362                 DO_ASSERT(get_jenv_res == JNI_OK);
14363         }
14364         LDKRoute route_var = *route;
14365         int64_t route_ref = 0;
14366         route_var = Route_clone(&route_var);
14367         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14368         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14369         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14370         route_ref = (uintptr_t)route_var.inner;
14371         if (route_var.is_owned) {
14372                 route_ref |= 1;
14373         }
14374         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
14375         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
14376         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
14377         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
14378         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14379         CHECK(obj != NULL);
14380         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
14381         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14382                 (*env)->ExceptionDescribe(env);
14383                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
14384         }
14385         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14386         CHECK_ACCESS(ret_ptr);
14387         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
14388         FREE((void*)ret);
14389         if (get_jenv_res == JNI_EDETACHED) {
14390                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14391         }
14392         return ret_conv;
14393 }
14394 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
14395         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14396         JNIEnv *env;
14397         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14398         if (get_jenv_res == JNI_EDETACHED) {
14399                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14400         } else {
14401                 DO_ASSERT(get_jenv_res == JNI_OK);
14402         }
14403         LDKRoute route_var = *route;
14404         int64_t route_ref = 0;
14405         route_var = Route_clone(&route_var);
14406         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14407         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14408         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14409         route_ref = (uintptr_t)route_var.inner;
14410         if (route_var.is_owned) {
14411                 route_ref |= 1;
14412         }
14413         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
14414         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
14415         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14416         CHECK(obj != NULL);
14417         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
14418         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14419                 (*env)->ExceptionDescribe(env);
14420                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
14421         }
14422         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14423         CHECK_ACCESS(ret_ptr);
14424         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
14425         FREE((void*)ret);
14426         if (get_jenv_res == JNI_EDETACHED) {
14427                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14428         }
14429         return ret_conv;
14430 }
14431 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
14432         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14433         JNIEnv *env;
14434         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14435         if (get_jenv_res == JNI_EDETACHED) {
14436                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14437         } else {
14438                 DO_ASSERT(get_jenv_res == JNI_OK);
14439         }
14440         LDKRoute route_var = *route;
14441         int64_t route_ref = 0;
14442         route_var = Route_clone(&route_var);
14443         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14444         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14445         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14446         route_ref = (uintptr_t)route_var.inner;
14447         if (route_var.is_owned) {
14448                 route_ref |= 1;
14449         }
14450         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
14451         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
14452         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14453         CHECK(obj != NULL);
14454         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
14455         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14456                 (*env)->ExceptionDescribe(env);
14457                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
14458         }
14459         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14460         CHECK_ACCESS(ret_ptr);
14461         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
14462         FREE((void*)ret);
14463         if (get_jenv_res == JNI_EDETACHED) {
14464                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14465         }
14466         return ret_conv;
14467 }
14468 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
14469         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14470         JNIEnv *env;
14471         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14472         if (get_jenv_res == JNI_EDETACHED) {
14473                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14474         } else {
14475                 DO_ASSERT(get_jenv_res == JNI_OK);
14476         }
14477         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
14478         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
14479         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14480         CHECK(obj != NULL);
14481         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
14482         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14483                 (*env)->ExceptionDescribe(env);
14484                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
14485         }
14486         if (get_jenv_res == JNI_EDETACHED) {
14487                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14488         }
14489 }
14490 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
14491         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
14492         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14493 }
14494 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
14495         jclass c = (*env)->GetObjectClass(env, o);
14496         CHECK(c != NULL);
14497         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
14498         atomic_init(&calls->refcnt, 1);
14499         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14500         calls->o = (*env)->NewWeakGlobalRef(env, o);
14501         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
14502         CHECK(calls->node_id_meth != NULL);
14503         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
14504         CHECK(calls->first_hops_meth != NULL);
14505         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
14506         CHECK(calls->send_payment_meth != NULL);
14507         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B)J");
14508         CHECK(calls->send_spontaneous_payment_meth != NULL);
14509         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
14510         CHECK(calls->retry_payment_meth != NULL);
14511         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
14512         CHECK(calls->abandon_payment_meth != NULL);
14513
14514         LDKPayer ret = {
14515                 .this_arg = (void*) calls,
14516                 .node_id = node_id_LDKPayer_jcall,
14517                 .first_hops = first_hops_LDKPayer_jcall,
14518                 .send_payment = send_payment_LDKPayer_jcall,
14519                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
14520                 .retry_payment = retry_payment_LDKPayer_jcall,
14521                 .abandon_payment = abandon_payment_LDKPayer_jcall,
14522                 .free = LDKPayer_JCalls_free,
14523         };
14524         return ret;
14525 }
14526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
14527         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
14528         *res_ptr = LDKPayer_init(env, clz, o);
14529         return (uint64_t)res_ptr;
14530 }
14531 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14532         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14533         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14534         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14535         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14536         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
14537         return ret_arr;
14538 }
14539
14540 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
14541         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14542         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14543         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14544         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
14545         int64_tArray ret_arr = NULL;
14546         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14547         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14548         for (size_t q = 0; q < ret_var.datalen; q++) {
14549                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
14550                 int64_t ret_conv_16_ref = 0;
14551                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14552                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14553                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
14554                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
14555                 if (ret_conv_16_var.is_owned) {
14556                         ret_conv_16_ref |= 1;
14557                 }
14558                 ret_arr_ptr[q] = ret_conv_16_ref;
14559         }
14560         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14561         FREE(ret_var.data);
14562         return ret_arr;
14563 }
14564
14565 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) {
14566         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14567         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14568         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14569         LDKRoute route_conv;
14570         route_conv.inner = (void*)(route & (~1));
14571         route_conv.is_owned = false;
14572         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14573         LDKThirtyTwoBytes payment_hash_ref;
14574         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14575         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
14576         LDKThirtyTwoBytes payment_secret_ref;
14577         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
14578         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
14579         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14580         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
14581         return (int64_t)ret_conv;
14582 }
14583
14584 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) {
14585         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14586         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14587         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14588         LDKRoute route_conv;
14589         route_conv.inner = (void*)(route & (~1));
14590         route_conv.is_owned = false;
14591         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14592         LDKThirtyTwoBytes payment_preimage_ref;
14593         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
14594         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
14595         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14596         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
14597         return (int64_t)ret_conv;
14598 }
14599
14600 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) {
14601         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14602         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14603         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14604         LDKRoute route_conv;
14605         route_conv.inner = (void*)(route & (~1));
14606         route_conv.is_owned = false;
14607         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14608         LDKThirtyTwoBytes payment_id_ref;
14609         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
14610         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
14611         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14612         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
14613         return (int64_t)ret_conv;
14614 }
14615
14616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
14617         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14618         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14619         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14620         LDKThirtyTwoBytes payment_id_ref;
14621         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
14622         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
14623         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
14624 }
14625
14626 typedef struct LDKRouter_JCalls {
14627         atomic_size_t refcnt;
14628         JavaVM *vm;
14629         jweak o;
14630         jmethodID find_route_meth;
14631 } LDKRouter_JCalls;
14632 static void LDKRouter_JCalls_free(void* this_arg) {
14633         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14634         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14635                 JNIEnv *env;
14636                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14637                 if (get_jenv_res == JNI_EDETACHED) {
14638                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14639                 } else {
14640                         DO_ASSERT(get_jenv_res == JNI_OK);
14641                 }
14642                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14643                 if (get_jenv_res == JNI_EDETACHED) {
14644                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14645                 }
14646                 FREE(j_calls);
14647         }
14648 }
14649 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) {
14650         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14651         JNIEnv *env;
14652         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14653         if (get_jenv_res == JNI_EDETACHED) {
14654                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14655         } else {
14656                 DO_ASSERT(get_jenv_res == JNI_OK);
14657         }
14658         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
14659         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
14660         LDKRouteParameters route_params_var = *route_params;
14661         int64_t route_params_ref = 0;
14662         route_params_var = RouteParameters_clone(&route_params_var);
14663         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14664         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14665         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
14666         route_params_ref = (uintptr_t)route_params_var.inner;
14667         if (route_params_var.is_owned) {
14668                 route_params_ref |= 1;
14669         }
14670         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
14671         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, *payment_hash);
14672         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
14673         int64_tArray first_hops_arr = NULL;
14674         if (first_hops != NULL) {
14675                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
14676                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
14677                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
14678                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
14679                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
14680                         int64_t first_hops_conv_16_ref = 0;
14681                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14682                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14683                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
14684                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
14685                         if (first_hops_conv_16_var.is_owned) {
14686                                 first_hops_conv_16_ref |= 1;
14687                         }
14688                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
14689                 }
14690                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
14691         }
14692         // WARNING: This object doesn't live past this scope, needs clone!
14693         int64_t ret_scorer = ((uintptr_t)scorer) | 1;
14694         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14695         CHECK(obj != NULL);
14696         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);
14697         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14698                 (*env)->ExceptionDescribe(env);
14699                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
14700         }
14701         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14702         CHECK_ACCESS(ret_ptr);
14703         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
14704         FREE((void*)ret);
14705         if (get_jenv_res == JNI_EDETACHED) {
14706                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14707         }
14708         return ret_conv;
14709 }
14710 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
14711         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
14712         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14713 }
14714 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
14715         jclass c = (*env)->GetObjectClass(env, o);
14716         CHECK(c != NULL);
14717         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
14718         atomic_init(&calls->refcnt, 1);
14719         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14720         calls->o = (*env)->NewWeakGlobalRef(env, o);
14721         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[B[JJ)J");
14722         CHECK(calls->find_route_meth != NULL);
14723
14724         LDKRouter ret = {
14725                 .this_arg = (void*) calls,
14726                 .find_route = find_route_LDKRouter_jcall,
14727                 .free = LDKRouter_JCalls_free,
14728         };
14729         return ret;
14730 }
14731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
14732         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
14733         *res_ptr = LDKRouter_init(env, clz, o);
14734         return (uint64_t)res_ptr;
14735 }
14736 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) {
14737         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14738         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14739         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
14740         LDKPublicKey payer_ref;
14741         CHECK((*env)->GetArrayLength(env, payer) == 33);
14742         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
14743         LDKRouteParameters route_params_conv;
14744         route_params_conv.inner = (void*)(route_params & (~1));
14745         route_params_conv.is_owned = false;
14746         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
14747         unsigned char payment_hash_arr[32];
14748         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14749         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
14750         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
14751         LDKCVec_ChannelDetailsZ first_hops_constr;
14752         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
14753         if (first_hops != NULL) {
14754                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
14755                 if (first_hops_constr.datalen > 0)
14756                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14757                 else
14758                         first_hops_constr.data = NULL;
14759                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
14760                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
14761                         int64_t first_hops_conv_16 = first_hops_vals[q];
14762                         LDKChannelDetails first_hops_conv_16_conv;
14763                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
14764                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
14765                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
14766                         first_hops_constr.data[q] = first_hops_conv_16_conv;
14767                 }
14768                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
14769                 first_hops_ptr = &first_hops_constr;
14770         }
14771         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
14772         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
14773         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
14774         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
14775         *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);
14776         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
14777         return (int64_t)ret_conv;
14778 }
14779
14780 static jclass LDKRetry_Attempts_class = NULL;
14781 static jmethodID LDKRetry_Attempts_meth = NULL;
14782 static jclass LDKRetry_Timeout_class = NULL;
14783 static jmethodID LDKRetry_Timeout_meth = NULL;
14784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKRetry_init (JNIEnv *env, jclass clz) {
14785         LDKRetry_Attempts_class =
14786                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Attempts"));
14787         CHECK(LDKRetry_Attempts_class != NULL);
14788         LDKRetry_Attempts_meth = (*env)->GetMethodID(env, LDKRetry_Attempts_class, "<init>", "(J)V");
14789         CHECK(LDKRetry_Attempts_meth != NULL);
14790         LDKRetry_Timeout_class =
14791                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Timeout"));
14792         CHECK(LDKRetry_Timeout_class != NULL);
14793         LDKRetry_Timeout_meth = (*env)->GetMethodID(env, LDKRetry_Timeout_class, "<init>", "(J)V");
14794         CHECK(LDKRetry_Timeout_meth != NULL);
14795 }
14796 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRetry_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14797         LDKRetry *obj = (LDKRetry*)(ptr & ~1);
14798         switch(obj->tag) {
14799                 case LDKRetry_Attempts: {
14800                         int64_t attempts_conv = obj->attempts;
14801                         return (*env)->NewObject(env, LDKRetry_Attempts_class, LDKRetry_Attempts_meth, attempts_conv);
14802                 }
14803                 case LDKRetry_Timeout: {
14804                         int64_t timeout_conv = obj->timeout;
14805                         return (*env)->NewObject(env, LDKRetry_Timeout_class, LDKRetry_Timeout_meth, timeout_conv);
14806                 }
14807                 default: abort();
14808         }
14809 }
14810 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
14811         LDKStr ret_str = _ldk_get_compiled_version();
14812         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
14813         Str_free(ret_str);
14814         return ret_conv;
14815 }
14816
14817 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
14818         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
14819         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
14820         Str_free(ret_str);
14821         return ret_conv;
14822 }
14823
14824 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
14825         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
14826         *ret_copy = Bech32Error_clone(arg);
14827 int64_t ret_ref = (uintptr_t)ret_copy;
14828         return ret_ref;
14829 }
14830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14831         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
14832         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
14833         return ret_conv;
14834 }
14835
14836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14837         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
14838         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
14839         *ret_copy = Bech32Error_clone(orig_conv);
14840         int64_t ret_ref = (uintptr_t)ret_copy;
14841         return ret_ref;
14842 }
14843
14844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bech32Error_1free(JNIEnv *env, jclass clz, int64_t o) {
14845         if ((o & 1) != 0) return;
14846         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14847         CHECK_ACCESS(o_ptr);
14848         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
14849         FREE((void*)o);
14850         Bech32Error_free(o_conv);
14851 }
14852
14853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
14854         LDKTransaction _res_ref;
14855         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
14856         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
14857         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
14858         _res_ref.data_is_owned = true;
14859         Transaction_free(_res_ref);
14860 }
14861
14862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
14863         LDKCVec_u8Z script_pubkey_ref;
14864         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
14865         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
14866         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
14867         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14868         *ret_ref = TxOut_new(script_pubkey_ref, value);
14869         return (int64_t)ret_ref;
14870 }
14871
14872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
14873         if ((_res & 1) != 0) return;
14874         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14875         CHECK_ACCESS(_res_ptr);
14876         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
14877         FREE((void*)_res);
14878         TxOut_free(_res_conv);
14879 }
14880
14881 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
14882         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14883         *ret_ref = TxOut_clone(arg);
14884         return (int64_t)ret_ref;
14885 }
14886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14887         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
14888         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
14889         return ret_conv;
14890 }
14891
14892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14893         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
14894         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14895         *ret_ref = TxOut_clone(orig_conv);
14896         return (int64_t)ret_ref;
14897 }
14898
14899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
14900         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
14901         Str_free(dummy);
14902 }
14903
14904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
14905         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14906         *ret_conv = CResult_NoneNoneZ_ok();
14907         return (int64_t)ret_conv;
14908 }
14909
14910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
14911         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14912         *ret_conv = CResult_NoneNoneZ_err();
14913         return (int64_t)ret_conv;
14914 }
14915
14916 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14917         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
14918         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
14919         return ret_conv;
14920 }
14921
14922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14923         if ((_res & 1) != 0) return;
14924         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14925         CHECK_ACCESS(_res_ptr);
14926         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
14927         FREE((void*)_res);
14928         CResult_NoneNoneZ_free(_res_conv);
14929 }
14930
14931 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
14932         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14933         *ret_conv = CResult_NoneNoneZ_clone(arg);
14934         return (int64_t)ret_conv;
14935 }
14936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14937         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
14938         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
14939         return ret_conv;
14940 }
14941
14942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14943         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
14944         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14945         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
14946         return (int64_t)ret_conv;
14947 }
14948
14949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14950         LDKCounterpartyCommitmentSecrets o_conv;
14951         o_conv.inner = (void*)(o & (~1));
14952         o_conv.is_owned = (o & 1) || (o == 0);
14953         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14954         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
14955         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14956         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
14957         return (int64_t)ret_conv;
14958 }
14959
14960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14961         LDKDecodeError e_conv;
14962         e_conv.inner = (void*)(e & (~1));
14963         e_conv.is_owned = (e & 1) || (e == 0);
14964         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14965         e_conv = DecodeError_clone(&e_conv);
14966         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14967         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
14968         return (int64_t)ret_conv;
14969 }
14970
14971 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14972         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
14973         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
14974         return ret_conv;
14975 }
14976
14977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14978         if ((_res & 1) != 0) return;
14979         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14980         CHECK_ACCESS(_res_ptr);
14981         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
14982         FREE((void*)_res);
14983         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
14984 }
14985
14986 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
14987         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14988         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
14989         return (int64_t)ret_conv;
14990 }
14991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14992         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
14993         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
14994         return ret_conv;
14995 }
14996
14997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14998         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
14999         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15000         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
15001         return (int64_t)ret_conv;
15002 }
15003
15004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15005         LDKSecretKey o_ref;
15006         CHECK((*env)->GetArrayLength(env, o) == 32);
15007         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
15008         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15009         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
15010         return (int64_t)ret_conv;
15011 }
15012
15013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15014         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15015         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15016         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
15017         return (int64_t)ret_conv;
15018 }
15019
15020 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15021         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
15022         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
15023         return ret_conv;
15024 }
15025
15026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15027         if ((_res & 1) != 0) return;
15028         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15029         CHECK_ACCESS(_res_ptr);
15030         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
15031         FREE((void*)_res);
15032         CResult_SecretKeyErrorZ_free(_res_conv);
15033 }
15034
15035 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
15036         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15037         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
15038         return (int64_t)ret_conv;
15039 }
15040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15041         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
15042         int64_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
15043         return ret_conv;
15044 }
15045
15046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15047         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
15048         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15049         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
15050         return (int64_t)ret_conv;
15051 }
15052
15053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15054         LDKPublicKey o_ref;
15055         CHECK((*env)->GetArrayLength(env, o) == 33);
15056         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
15057         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15058         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
15059         return (int64_t)ret_conv;
15060 }
15061
15062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15063         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15064         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15065         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
15066         return (int64_t)ret_conv;
15067 }
15068
15069 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15070         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
15071         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
15072         return ret_conv;
15073 }
15074
15075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15076         if ((_res & 1) != 0) return;
15077         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15078         CHECK_ACCESS(_res_ptr);
15079         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
15080         FREE((void*)_res);
15081         CResult_PublicKeyErrorZ_free(_res_conv);
15082 }
15083
15084 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
15085         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15086         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
15087         return (int64_t)ret_conv;
15088 }
15089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15090         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
15091         int64_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
15092         return ret_conv;
15093 }
15094
15095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15096         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
15097         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15098         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
15099         return (int64_t)ret_conv;
15100 }
15101
15102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15103         LDKTxCreationKeys o_conv;
15104         o_conv.inner = (void*)(o & (~1));
15105         o_conv.is_owned = (o & 1) || (o == 0);
15106         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15107         o_conv = TxCreationKeys_clone(&o_conv);
15108         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15109         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
15110         return (int64_t)ret_conv;
15111 }
15112
15113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15114         LDKDecodeError e_conv;
15115         e_conv.inner = (void*)(e & (~1));
15116         e_conv.is_owned = (e & 1) || (e == 0);
15117         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15118         e_conv = DecodeError_clone(&e_conv);
15119         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15120         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
15121         return (int64_t)ret_conv;
15122 }
15123
15124 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15125         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
15126         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
15127         return ret_conv;
15128 }
15129
15130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15131         if ((_res & 1) != 0) return;
15132         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15133         CHECK_ACCESS(_res_ptr);
15134         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
15135         FREE((void*)_res);
15136         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
15137 }
15138
15139 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
15140         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15141         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
15142         return (int64_t)ret_conv;
15143 }
15144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15145         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
15146         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
15147         return ret_conv;
15148 }
15149
15150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15151         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
15152         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15153         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
15154         return (int64_t)ret_conv;
15155 }
15156
15157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15158         LDKChannelPublicKeys o_conv;
15159         o_conv.inner = (void*)(o & (~1));
15160         o_conv.is_owned = (o & 1) || (o == 0);
15161         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15162         o_conv = ChannelPublicKeys_clone(&o_conv);
15163         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15164         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
15165         return (int64_t)ret_conv;
15166 }
15167
15168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15169         LDKDecodeError e_conv;
15170         e_conv.inner = (void*)(e & (~1));
15171         e_conv.is_owned = (e & 1) || (e == 0);
15172         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15173         e_conv = DecodeError_clone(&e_conv);
15174         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15175         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
15176         return (int64_t)ret_conv;
15177 }
15178
15179 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15180         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
15181         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
15182         return ret_conv;
15183 }
15184
15185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15186         if ((_res & 1) != 0) return;
15187         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15188         CHECK_ACCESS(_res_ptr);
15189         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
15190         FREE((void*)_res);
15191         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
15192 }
15193
15194 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
15195         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15196         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
15197         return (int64_t)ret_conv;
15198 }
15199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15200         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
15201         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
15202         return ret_conv;
15203 }
15204
15205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15206         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
15207         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15208         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
15209         return (int64_t)ret_conv;
15210 }
15211
15212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15213         LDKTxCreationKeys o_conv;
15214         o_conv.inner = (void*)(o & (~1));
15215         o_conv.is_owned = (o & 1) || (o == 0);
15216         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15217         o_conv = TxCreationKeys_clone(&o_conv);
15218         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15219         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
15220         return (int64_t)ret_conv;
15221 }
15222
15223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15224         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15225         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15226         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
15227         return (int64_t)ret_conv;
15228 }
15229
15230 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15231         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
15232         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
15233         return ret_conv;
15234 }
15235
15236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15237         if ((_res & 1) != 0) return;
15238         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15239         CHECK_ACCESS(_res_ptr);
15240         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
15241         FREE((void*)_res);
15242         CResult_TxCreationKeysErrorZ_free(_res_conv);
15243 }
15244
15245 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
15246         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15247         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
15248         return (int64_t)ret_conv;
15249 }
15250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15251         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
15252         int64_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
15253         return ret_conv;
15254 }
15255
15256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15257         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
15258         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15259         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
15260         return (int64_t)ret_conv;
15261 }
15262
15263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
15264         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15265         *ret_copy = COption_u32Z_some(o);
15266         int64_t ret_ref = (uintptr_t)ret_copy;
15267         return ret_ref;
15268 }
15269
15270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
15271         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15272         *ret_copy = COption_u32Z_none();
15273         int64_t ret_ref = (uintptr_t)ret_copy;
15274         return ret_ref;
15275 }
15276
15277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
15278         if ((_res & 1) != 0) return;
15279         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15280         CHECK_ACCESS(_res_ptr);
15281         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
15282         FREE((void*)_res);
15283         COption_u32Z_free(_res_conv);
15284 }
15285
15286 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
15287         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15288         *ret_copy = COption_u32Z_clone(arg);
15289 int64_t ret_ref = (uintptr_t)ret_copy;
15290         return ret_ref;
15291 }
15292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15293         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
15294         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
15295         return ret_conv;
15296 }
15297
15298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15299         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
15300         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15301         *ret_copy = COption_u32Z_clone(orig_conv);
15302         int64_t ret_ref = (uintptr_t)ret_copy;
15303         return ret_ref;
15304 }
15305
15306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15307         LDKHTLCOutputInCommitment o_conv;
15308         o_conv.inner = (void*)(o & (~1));
15309         o_conv.is_owned = (o & 1) || (o == 0);
15310         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15311         o_conv = HTLCOutputInCommitment_clone(&o_conv);
15312         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15313         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
15314         return (int64_t)ret_conv;
15315 }
15316
15317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15318         LDKDecodeError e_conv;
15319         e_conv.inner = (void*)(e & (~1));
15320         e_conv.is_owned = (e & 1) || (e == 0);
15321         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15322         e_conv = DecodeError_clone(&e_conv);
15323         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15324         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
15325         return (int64_t)ret_conv;
15326 }
15327
15328 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15329         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
15330         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
15331         return ret_conv;
15332 }
15333
15334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15335         if ((_res & 1) != 0) return;
15336         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15337         CHECK_ACCESS(_res_ptr);
15338         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
15339         FREE((void*)_res);
15340         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
15341 }
15342
15343 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
15344         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15345         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
15346         return (int64_t)ret_conv;
15347 }
15348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15349         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
15350         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
15351         return ret_conv;
15352 }
15353
15354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15355         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
15356         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15357         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
15358         return (int64_t)ret_conv;
15359 }
15360
15361 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
15362         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
15363         return ret_conv;
15364 }
15365
15366 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
15367         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
15368         return ret_conv;
15369 }
15370
15371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
15372         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
15373         COption_NoneZ_free(_res_conv);
15374 }
15375
15376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15377         LDKCounterpartyChannelTransactionParameters o_conv;
15378         o_conv.inner = (void*)(o & (~1));
15379         o_conv.is_owned = (o & 1) || (o == 0);
15380         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15381         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
15382         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15383         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
15384         return (int64_t)ret_conv;
15385 }
15386
15387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15388         LDKDecodeError e_conv;
15389         e_conv.inner = (void*)(e & (~1));
15390         e_conv.is_owned = (e & 1) || (e == 0);
15391         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15392         e_conv = DecodeError_clone(&e_conv);
15393         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15394         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
15395         return (int64_t)ret_conv;
15396 }
15397
15398 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15399         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
15400         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
15401         return ret_conv;
15402 }
15403
15404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15405         if ((_res & 1) != 0) return;
15406         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15407         CHECK_ACCESS(_res_ptr);
15408         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
15409         FREE((void*)_res);
15410         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
15411 }
15412
15413 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
15414         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15415         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
15416         return (int64_t)ret_conv;
15417 }
15418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15419         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
15420         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
15421         return ret_conv;
15422 }
15423
15424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15425         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
15426         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15427         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
15428         return (int64_t)ret_conv;
15429 }
15430
15431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15432         LDKChannelTransactionParameters o_conv;
15433         o_conv.inner = (void*)(o & (~1));
15434         o_conv.is_owned = (o & 1) || (o == 0);
15435         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15436         o_conv = ChannelTransactionParameters_clone(&o_conv);
15437         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15438         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
15439         return (int64_t)ret_conv;
15440 }
15441
15442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15443         LDKDecodeError e_conv;
15444         e_conv.inner = (void*)(e & (~1));
15445         e_conv.is_owned = (e & 1) || (e == 0);
15446         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15447         e_conv = DecodeError_clone(&e_conv);
15448         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15449         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
15450         return (int64_t)ret_conv;
15451 }
15452
15453 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15454         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
15455         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
15456         return ret_conv;
15457 }
15458
15459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15460         if ((_res & 1) != 0) return;
15461         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15462         CHECK_ACCESS(_res_ptr);
15463         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
15464         FREE((void*)_res);
15465         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
15466 }
15467
15468 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
15469         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15470         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
15471         return (int64_t)ret_conv;
15472 }
15473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15474         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
15475         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
15476         return ret_conv;
15477 }
15478
15479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15480         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
15481         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15482         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
15483         return (int64_t)ret_conv;
15484 }
15485
15486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15487         LDKCVec_SignatureZ _res_constr;
15488         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15489         if (_res_constr.datalen > 0)
15490                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15491         else
15492                 _res_constr.data = NULL;
15493         for (size_t i = 0; i < _res_constr.datalen; i++) {
15494                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15495                 LDKSignature _res_conv_8_ref;
15496                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
15497                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
15498                 _res_constr.data[i] = _res_conv_8_ref;
15499         }
15500         CVec_SignatureZ_free(_res_constr);
15501 }
15502
15503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15504         LDKHolderCommitmentTransaction o_conv;
15505         o_conv.inner = (void*)(o & (~1));
15506         o_conv.is_owned = (o & 1) || (o == 0);
15507         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15508         o_conv = HolderCommitmentTransaction_clone(&o_conv);
15509         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15510         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
15511         return (int64_t)ret_conv;
15512 }
15513
15514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15515         LDKDecodeError e_conv;
15516         e_conv.inner = (void*)(e & (~1));
15517         e_conv.is_owned = (e & 1) || (e == 0);
15518         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15519         e_conv = DecodeError_clone(&e_conv);
15520         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15521         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
15522         return (int64_t)ret_conv;
15523 }
15524
15525 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15526         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
15527         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15528         return ret_conv;
15529 }
15530
15531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15532         if ((_res & 1) != 0) return;
15533         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15534         CHECK_ACCESS(_res_ptr);
15535         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
15536         FREE((void*)_res);
15537         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
15538 }
15539
15540 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15541         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15542         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
15543         return (int64_t)ret_conv;
15544 }
15545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15546         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
15547         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15548         return ret_conv;
15549 }
15550
15551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15552         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
15553         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15554         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
15555         return (int64_t)ret_conv;
15556 }
15557
15558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15559         LDKBuiltCommitmentTransaction o_conv;
15560         o_conv.inner = (void*)(o & (~1));
15561         o_conv.is_owned = (o & 1) || (o == 0);
15562         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15563         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
15564         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15565         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
15566         return (int64_t)ret_conv;
15567 }
15568
15569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15570         LDKDecodeError e_conv;
15571         e_conv.inner = (void*)(e & (~1));
15572         e_conv.is_owned = (e & 1) || (e == 0);
15573         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15574         e_conv = DecodeError_clone(&e_conv);
15575         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15576         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
15577         return (int64_t)ret_conv;
15578 }
15579
15580 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15581         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
15582         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15583         return ret_conv;
15584 }
15585
15586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15587         if ((_res & 1) != 0) return;
15588         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15589         CHECK_ACCESS(_res_ptr);
15590         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
15591         FREE((void*)_res);
15592         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
15593 }
15594
15595 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15596         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15597         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
15598         return (int64_t)ret_conv;
15599 }
15600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15601         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
15602         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15603         return ret_conv;
15604 }
15605
15606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15607         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
15608         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15609         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
15610         return (int64_t)ret_conv;
15611 }
15612
15613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15614         LDKTrustedClosingTransaction o_conv;
15615         o_conv.inner = (void*)(o & (~1));
15616         o_conv.is_owned = (o & 1) || (o == 0);
15617         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15618         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
15619         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
15620         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
15621         return (int64_t)ret_conv;
15622 }
15623
15624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
15625         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
15626         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
15627         return (int64_t)ret_conv;
15628 }
15629
15630 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15631         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
15632         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
15633         return ret_conv;
15634 }
15635
15636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15637         if ((_res & 1) != 0) return;
15638         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15639         CHECK_ACCESS(_res_ptr);
15640         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
15641         FREE((void*)_res);
15642         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
15643 }
15644
15645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15646         LDKCommitmentTransaction o_conv;
15647         o_conv.inner = (void*)(o & (~1));
15648         o_conv.is_owned = (o & 1) || (o == 0);
15649         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15650         o_conv = CommitmentTransaction_clone(&o_conv);
15651         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15652         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
15653         return (int64_t)ret_conv;
15654 }
15655
15656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15657         LDKDecodeError e_conv;
15658         e_conv.inner = (void*)(e & (~1));
15659         e_conv.is_owned = (e & 1) || (e == 0);
15660         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15661         e_conv = DecodeError_clone(&e_conv);
15662         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15663         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
15664         return (int64_t)ret_conv;
15665 }
15666
15667 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15668         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
15669         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15670         return ret_conv;
15671 }
15672
15673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15674         if ((_res & 1) != 0) return;
15675         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15676         CHECK_ACCESS(_res_ptr);
15677         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
15678         FREE((void*)_res);
15679         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
15680 }
15681
15682 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15683         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15684         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
15685         return (int64_t)ret_conv;
15686 }
15687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15688         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
15689         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15690         return ret_conv;
15691 }
15692
15693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15694         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
15695         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15696         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
15697         return (int64_t)ret_conv;
15698 }
15699
15700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15701         LDKTrustedCommitmentTransaction o_conv;
15702         o_conv.inner = (void*)(o & (~1));
15703         o_conv.is_owned = (o & 1) || (o == 0);
15704         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15705         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
15706         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
15707         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
15708         return (int64_t)ret_conv;
15709 }
15710
15711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
15712         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
15713         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
15714         return (int64_t)ret_conv;
15715 }
15716
15717 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15718         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
15719         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
15720         return ret_conv;
15721 }
15722
15723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15724         if ((_res & 1) != 0) return;
15725         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15726         CHECK_ACCESS(_res_ptr);
15727         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
15728         FREE((void*)_res);
15729         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
15730 }
15731
15732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
15733         LDKCVec_SignatureZ o_constr;
15734         o_constr.datalen = (*env)->GetArrayLength(env, o);
15735         if (o_constr.datalen > 0)
15736                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15737         else
15738                 o_constr.data = NULL;
15739         for (size_t i = 0; i < o_constr.datalen; i++) {
15740                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
15741                 LDKSignature o_conv_8_ref;
15742                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
15743                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
15744                 o_constr.data[i] = o_conv_8_ref;
15745         }
15746         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15747         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
15748         return (int64_t)ret_conv;
15749 }
15750
15751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
15752         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15753         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
15754         return (int64_t)ret_conv;
15755 }
15756
15757 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15758         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
15759         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
15760         return ret_conv;
15761 }
15762
15763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15764         if ((_res & 1) != 0) return;
15765         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15766         CHECK_ACCESS(_res_ptr);
15767         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
15768         FREE((void*)_res);
15769         CResult_CVec_SignatureZNoneZ_free(_res_conv);
15770 }
15771
15772 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
15773         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15774         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
15775         return (int64_t)ret_conv;
15776 }
15777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15778         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
15779         int64_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
15780         return ret_conv;
15781 }
15782
15783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15784         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
15785         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15786         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
15787         return (int64_t)ret_conv;
15788 }
15789
15790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15791         LDKShutdownScript 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 = ShutdownScript_clone(&o_conv);
15796         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15797         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
15798         return (int64_t)ret_conv;
15799 }
15800
15801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_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_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15808         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
15809         return (int64_t)ret_conv;
15810 }
15811
15812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15813         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
15814         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
15815         return ret_conv;
15816 }
15817
15818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_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_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
15823         FREE((void*)_res);
15824         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
15825 }
15826
15827 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
15828         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15829         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
15830         return (int64_t)ret_conv;
15831 }
15832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15833         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
15834         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
15835         return ret_conv;
15836 }
15837
15838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15839         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
15840         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15841         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
15842         return (int64_t)ret_conv;
15843 }
15844
15845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15846         LDKShutdownScript o_conv;
15847         o_conv.inner = (void*)(o & (~1));
15848         o_conv.is_owned = (o & 1) || (o == 0);
15849         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15850         o_conv = ShutdownScript_clone(&o_conv);
15851         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15852         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
15853         return (int64_t)ret_conv;
15854 }
15855
15856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15857         LDKInvalidShutdownScript e_conv;
15858         e_conv.inner = (void*)(e & (~1));
15859         e_conv.is_owned = (e & 1) || (e == 0);
15860         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15861         e_conv = InvalidShutdownScript_clone(&e_conv);
15862         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15863         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
15864         return (int64_t)ret_conv;
15865 }
15866
15867 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15868         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
15869         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
15870         return ret_conv;
15871 }
15872
15873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15874         if ((_res & 1) != 0) return;
15875         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15876         CHECK_ACCESS(_res_ptr);
15877         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
15878         FREE((void*)_res);
15879         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
15880 }
15881
15882 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
15883         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15884         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
15885         return (int64_t)ret_conv;
15886 }
15887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15888         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
15889         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
15890         return ret_conv;
15891 }
15892
15893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15894         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
15895         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15896         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
15897         return (int64_t)ret_conv;
15898 }
15899
15900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
15901         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15902         *ret_conv = CResult_NoneErrorZ_ok();
15903         return (int64_t)ret_conv;
15904 }
15905
15906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15907         LDKIOError e_conv = LDKIOError_from_java(env, e);
15908         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15909         *ret_conv = CResult_NoneErrorZ_err(e_conv);
15910         return (int64_t)ret_conv;
15911 }
15912
15913 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15914         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
15915         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
15916         return ret_conv;
15917 }
15918
15919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15920         if ((_res & 1) != 0) return;
15921         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15922         CHECK_ACCESS(_res_ptr);
15923         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
15924         FREE((void*)_res);
15925         CResult_NoneErrorZ_free(_res_conv);
15926 }
15927
15928 static inline uintptr_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
15929         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15930         *ret_conv = CResult_NoneErrorZ_clone(arg);
15931         return (int64_t)ret_conv;
15932 }
15933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15934         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
15935         int64_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
15936         return ret_conv;
15937 }
15938
15939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15940         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
15941         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15942         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
15943         return (int64_t)ret_conv;
15944 }
15945
15946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15947         LDKRouteHop o_conv;
15948         o_conv.inner = (void*)(o & (~1));
15949         o_conv.is_owned = (o & 1) || (o == 0);
15950         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15951         o_conv = RouteHop_clone(&o_conv);
15952         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15953         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
15954         return (int64_t)ret_conv;
15955 }
15956
15957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15958         LDKDecodeError e_conv;
15959         e_conv.inner = (void*)(e & (~1));
15960         e_conv.is_owned = (e & 1) || (e == 0);
15961         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15962         e_conv = DecodeError_clone(&e_conv);
15963         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15964         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
15965         return (int64_t)ret_conv;
15966 }
15967
15968 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15969         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
15970         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
15971         return ret_conv;
15972 }
15973
15974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15975         if ((_res & 1) != 0) return;
15976         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15977         CHECK_ACCESS(_res_ptr);
15978         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
15979         FREE((void*)_res);
15980         CResult_RouteHopDecodeErrorZ_free(_res_conv);
15981 }
15982
15983 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
15984         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15985         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
15986         return (int64_t)ret_conv;
15987 }
15988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15989         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
15990         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
15991         return ret_conv;
15992 }
15993
15994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15995         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
15996         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15997         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
15998         return (int64_t)ret_conv;
15999 }
16000
16001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16002         LDKCVec_RouteHopZ _res_constr;
16003         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16004         if (_res_constr.datalen > 0)
16005                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16006         else
16007                 _res_constr.data = NULL;
16008         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16009         for (size_t k = 0; k < _res_constr.datalen; k++) {
16010                 int64_t _res_conv_10 = _res_vals[k];
16011                 LDKRouteHop _res_conv_10_conv;
16012                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
16013                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
16014                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
16015                 _res_constr.data[k] = _res_conv_10_conv;
16016         }
16017         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16018         CVec_RouteHopZ_free(_res_constr);
16019 }
16020
16021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16022         LDKCVec_CVec_RouteHopZZ _res_constr;
16023         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16024         if (_res_constr.datalen > 0)
16025                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
16026         else
16027                 _res_constr.data = NULL;
16028         for (size_t m = 0; m < _res_constr.datalen; m++) {
16029                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
16030                 LDKCVec_RouteHopZ _res_conv_12_constr;
16031                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
16032                 if (_res_conv_12_constr.datalen > 0)
16033                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16034                 else
16035                         _res_conv_12_constr.data = NULL;
16036                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
16037                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
16038                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
16039                         LDKRouteHop _res_conv_12_conv_10_conv;
16040                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
16041                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
16042                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
16043                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
16044                 }
16045                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
16046                 _res_constr.data[m] = _res_conv_12_constr;
16047         }
16048         CVec_CVec_RouteHopZZ_free(_res_constr);
16049 }
16050
16051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16052         LDKRoute o_conv;
16053         o_conv.inner = (void*)(o & (~1));
16054         o_conv.is_owned = (o & 1) || (o == 0);
16055         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16056         o_conv = Route_clone(&o_conv);
16057         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16058         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
16059         return (int64_t)ret_conv;
16060 }
16061
16062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16063         LDKDecodeError e_conv;
16064         e_conv.inner = (void*)(e & (~1));
16065         e_conv.is_owned = (e & 1) || (e == 0);
16066         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16067         e_conv = DecodeError_clone(&e_conv);
16068         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16069         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
16070         return (int64_t)ret_conv;
16071 }
16072
16073 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16074         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
16075         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
16076         return ret_conv;
16077 }
16078
16079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16080         if ((_res & 1) != 0) return;
16081         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16082         CHECK_ACCESS(_res_ptr);
16083         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
16084         FREE((void*)_res);
16085         CResult_RouteDecodeErrorZ_free(_res_conv);
16086 }
16087
16088 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
16089         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16090         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
16091         return (int64_t)ret_conv;
16092 }
16093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16094         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
16095         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
16096         return ret_conv;
16097 }
16098
16099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16100         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
16101         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16102         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
16103         return (int64_t)ret_conv;
16104 }
16105
16106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16107         LDKRouteParameters o_conv;
16108         o_conv.inner = (void*)(o & (~1));
16109         o_conv.is_owned = (o & 1) || (o == 0);
16110         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16111         o_conv = RouteParameters_clone(&o_conv);
16112         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16113         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
16114         return (int64_t)ret_conv;
16115 }
16116
16117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16118         LDKDecodeError e_conv;
16119         e_conv.inner = (void*)(e & (~1));
16120         e_conv.is_owned = (e & 1) || (e == 0);
16121         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16122         e_conv = DecodeError_clone(&e_conv);
16123         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16124         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
16125         return (int64_t)ret_conv;
16126 }
16127
16128 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16129         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
16130         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
16131         return ret_conv;
16132 }
16133
16134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16135         if ((_res & 1) != 0) return;
16136         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16137         CHECK_ACCESS(_res_ptr);
16138         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
16139         FREE((void*)_res);
16140         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
16141 }
16142
16143 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
16144         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16145         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
16146         return (int64_t)ret_conv;
16147 }
16148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16149         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
16150         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
16151         return ret_conv;
16152 }
16153
16154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16155         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
16156         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16157         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
16158         return (int64_t)ret_conv;
16159 }
16160
16161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16162         LDKCVec_RouteHintZ _res_constr;
16163         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16164         if (_res_constr.datalen > 0)
16165                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
16166         else
16167                 _res_constr.data = NULL;
16168         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16169         for (size_t l = 0; l < _res_constr.datalen; l++) {
16170                 int64_t _res_conv_11 = _res_vals[l];
16171                 LDKRouteHint _res_conv_11_conv;
16172                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
16173                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
16174                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
16175                 _res_constr.data[l] = _res_conv_11_conv;
16176         }
16177         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16178         CVec_RouteHintZ_free(_res_constr);
16179 }
16180
16181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
16182         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16183         *ret_copy = COption_u64Z_some(o);
16184         int64_t ret_ref = (uintptr_t)ret_copy;
16185         return ret_ref;
16186 }
16187
16188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
16189         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16190         *ret_copy = COption_u64Z_none();
16191         int64_t ret_ref = (uintptr_t)ret_copy;
16192         return ret_ref;
16193 }
16194
16195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_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         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
16200         FREE((void*)_res);
16201         COption_u64Z_free(_res_conv);
16202 }
16203
16204 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
16205         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16206         *ret_copy = COption_u64Z_clone(arg);
16207 int64_t ret_ref = (uintptr_t)ret_copy;
16208         return ret_ref;
16209 }
16210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16211         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
16212         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
16213         return ret_conv;
16214 }
16215
16216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16217         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
16218         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16219         *ret_copy = COption_u64Z_clone(orig_conv);
16220         int64_t ret_ref = (uintptr_t)ret_copy;
16221         return ret_ref;
16222 }
16223
16224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16225         LDKCVec_u64Z _res_constr;
16226         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16227         if (_res_constr.datalen > 0)
16228                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16229         else
16230                 _res_constr.data = NULL;
16231         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16232         for (size_t g = 0; g < _res_constr.datalen; g++) {
16233                 int64_t _res_conv_6 = _res_vals[g];
16234                 _res_constr.data[g] = _res_conv_6;
16235         }
16236         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16237         CVec_u64Z_free(_res_constr);
16238 }
16239
16240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16241         LDKPaymentParameters o_conv;
16242         o_conv.inner = (void*)(o & (~1));
16243         o_conv.is_owned = (o & 1) || (o == 0);
16244         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16245         o_conv = PaymentParameters_clone(&o_conv);
16246         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16247         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
16248         return (int64_t)ret_conv;
16249 }
16250
16251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16252         LDKDecodeError e_conv;
16253         e_conv.inner = (void*)(e & (~1));
16254         e_conv.is_owned = (e & 1) || (e == 0);
16255         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16256         e_conv = DecodeError_clone(&e_conv);
16257         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16258         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
16259         return (int64_t)ret_conv;
16260 }
16261
16262 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16263         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
16264         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
16265         return ret_conv;
16266 }
16267
16268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16269         if ((_res & 1) != 0) return;
16270         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16271         CHECK_ACCESS(_res_ptr);
16272         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
16273         FREE((void*)_res);
16274         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
16275 }
16276
16277 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
16278         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16279         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
16280         return (int64_t)ret_conv;
16281 }
16282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16283         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
16284         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
16285         return ret_conv;
16286 }
16287
16288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16289         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
16290         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16291         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
16292         return (int64_t)ret_conv;
16293 }
16294
16295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16296         LDKCVec_RouteHintHopZ _res_constr;
16297         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16298         if (_res_constr.datalen > 0)
16299                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
16300         else
16301                 _res_constr.data = NULL;
16302         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16303         for (size_t o = 0; o < _res_constr.datalen; o++) {
16304                 int64_t _res_conv_14 = _res_vals[o];
16305                 LDKRouteHintHop _res_conv_14_conv;
16306                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
16307                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
16308                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
16309                 _res_constr.data[o] = _res_conv_14_conv;
16310         }
16311         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16312         CVec_RouteHintHopZ_free(_res_constr);
16313 }
16314
16315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16316         LDKRouteHint o_conv;
16317         o_conv.inner = (void*)(o & (~1));
16318         o_conv.is_owned = (o & 1) || (o == 0);
16319         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16320         o_conv = RouteHint_clone(&o_conv);
16321         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16322         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
16323         return (int64_t)ret_conv;
16324 }
16325
16326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16327         LDKDecodeError e_conv;
16328         e_conv.inner = (void*)(e & (~1));
16329         e_conv.is_owned = (e & 1) || (e == 0);
16330         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16331         e_conv = DecodeError_clone(&e_conv);
16332         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16333         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
16334         return (int64_t)ret_conv;
16335 }
16336
16337 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16338         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
16339         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
16340         return ret_conv;
16341 }
16342
16343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16344         if ((_res & 1) != 0) return;
16345         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16346         CHECK_ACCESS(_res_ptr);
16347         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
16348         FREE((void*)_res);
16349         CResult_RouteHintDecodeErrorZ_free(_res_conv);
16350 }
16351
16352 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
16353         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16354         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
16355         return (int64_t)ret_conv;
16356 }
16357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16358         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
16359         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
16360         return ret_conv;
16361 }
16362
16363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16364         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
16365         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16366         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
16367         return (int64_t)ret_conv;
16368 }
16369
16370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16371         LDKRouteHintHop o_conv;
16372         o_conv.inner = (void*)(o & (~1));
16373         o_conv.is_owned = (o & 1) || (o == 0);
16374         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16375         o_conv = RouteHintHop_clone(&o_conv);
16376         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16377         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
16378         return (int64_t)ret_conv;
16379 }
16380
16381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16382         LDKDecodeError e_conv;
16383         e_conv.inner = (void*)(e & (~1));
16384         e_conv.is_owned = (e & 1) || (e == 0);
16385         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16386         e_conv = DecodeError_clone(&e_conv);
16387         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16388         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
16389         return (int64_t)ret_conv;
16390 }
16391
16392 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16393         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
16394         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
16395         return ret_conv;
16396 }
16397
16398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16399         if ((_res & 1) != 0) return;
16400         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16401         CHECK_ACCESS(_res_ptr);
16402         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
16403         FREE((void*)_res);
16404         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
16405 }
16406
16407 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
16408         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16409         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
16410         return (int64_t)ret_conv;
16411 }
16412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16413         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
16414         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
16415         return ret_conv;
16416 }
16417
16418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16419         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
16420         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16421         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
16422         return (int64_t)ret_conv;
16423 }
16424
16425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16426         LDKCVec_ChannelDetailsZ _res_constr;
16427         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16428         if (_res_constr.datalen > 0)
16429                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
16430         else
16431                 _res_constr.data = NULL;
16432         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16433         for (size_t q = 0; q < _res_constr.datalen; q++) {
16434                 int64_t _res_conv_16 = _res_vals[q];
16435                 LDKChannelDetails _res_conv_16_conv;
16436                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
16437                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
16438                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
16439                 _res_constr.data[q] = _res_conv_16_conv;
16440         }
16441         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16442         CVec_ChannelDetailsZ_free(_res_constr);
16443 }
16444
16445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16446         LDKRoute o_conv;
16447         o_conv.inner = (void*)(o & (~1));
16448         o_conv.is_owned = (o & 1) || (o == 0);
16449         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16450         o_conv = Route_clone(&o_conv);
16451         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16452         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
16453         return (int64_t)ret_conv;
16454 }
16455
16456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16457         LDKLightningError e_conv;
16458         e_conv.inner = (void*)(e & (~1));
16459         e_conv.is_owned = (e & 1) || (e == 0);
16460         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16461         e_conv = LightningError_clone(&e_conv);
16462         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16463         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
16464         return (int64_t)ret_conv;
16465 }
16466
16467 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16468         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
16469         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
16470         return ret_conv;
16471 }
16472
16473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16474         if ((_res & 1) != 0) return;
16475         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16476         CHECK_ACCESS(_res_ptr);
16477         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
16478         FREE((void*)_res);
16479         CResult_RouteLightningErrorZ_free(_res_conv);
16480 }
16481
16482 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
16483         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16484         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
16485         return (int64_t)ret_conv;
16486 }
16487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16488         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
16489         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
16490         return ret_conv;
16491 }
16492
16493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16494         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
16495         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16496         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
16497         return (int64_t)ret_conv;
16498 }
16499
16500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16501         LDKCVec_PublicKeyZ _res_constr;
16502         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16503         if (_res_constr.datalen > 0)
16504                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
16505         else
16506                 _res_constr.data = NULL;
16507         for (size_t i = 0; i < _res_constr.datalen; i++) {
16508                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16509                 LDKPublicKey _res_conv_8_ref;
16510                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
16511                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
16512                 _res_constr.data[i] = _res_conv_8_ref;
16513         }
16514         CVec_PublicKeyZ_free(_res_constr);
16515 }
16516
16517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16518         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16519         CHECK_ACCESS(o_ptr);
16520         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
16521         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)o) & ~1));
16522         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16523         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
16524         return (int64_t)ret_conv;
16525 }
16526
16527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16528         LDKDecodeError e_conv;
16529         e_conv.inner = (void*)(e & (~1));
16530         e_conv.is_owned = (e & 1) || (e == 0);
16531         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16532         e_conv = DecodeError_clone(&e_conv);
16533         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16534         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
16535         return (int64_t)ret_conv;
16536 }
16537
16538 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16539         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(o & ~1);
16540         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
16541         return ret_conv;
16542 }
16543
16544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16545         if ((_res & 1) != 0) return;
16546         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16547         CHECK_ACCESS(_res_ptr);
16548         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
16549         FREE((void*)_res);
16550         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
16551 }
16552
16553 static inline uintptr_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
16554         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16555         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
16556         return (int64_t)ret_conv;
16557 }
16558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16559         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(arg & ~1);
16560         int64_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
16561         return ret_conv;
16562 }
16563
16564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16565         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(orig & ~1);
16566         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16567         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
16568         return (int64_t)ret_conv;
16569 }
16570
16571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16572         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16573         CHECK_ACCESS(o_ptr);
16574         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
16575         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
16576         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16577         *ret_copy = COption_ClosureReasonZ_some(o_conv);
16578         int64_t ret_ref = (uintptr_t)ret_copy;
16579         return ret_ref;
16580 }
16581
16582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
16583         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16584         *ret_copy = COption_ClosureReasonZ_none();
16585         int64_t ret_ref = (uintptr_t)ret_copy;
16586         return ret_ref;
16587 }
16588
16589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16590         if ((_res & 1) != 0) return;
16591         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16592         CHECK_ACCESS(_res_ptr);
16593         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
16594         FREE((void*)_res);
16595         COption_ClosureReasonZ_free(_res_conv);
16596 }
16597
16598 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
16599         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16600         *ret_copy = COption_ClosureReasonZ_clone(arg);
16601 int64_t ret_ref = (uintptr_t)ret_copy;
16602         return ret_ref;
16603 }
16604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16605         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
16606         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
16607         return ret_conv;
16608 }
16609
16610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16611         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
16612         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16613         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
16614         int64_t ret_ref = (uintptr_t)ret_copy;
16615         return ret_ref;
16616 }
16617
16618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16619         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16620         CHECK_ACCESS(o_ptr);
16621         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
16622         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
16623         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16624         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
16625         return (int64_t)ret_conv;
16626 }
16627
16628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16629         LDKDecodeError e_conv;
16630         e_conv.inner = (void*)(e & (~1));
16631         e_conv.is_owned = (e & 1) || (e == 0);
16632         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16633         e_conv = DecodeError_clone(&e_conv);
16634         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16635         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
16636         return (int64_t)ret_conv;
16637 }
16638
16639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16640         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
16641         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
16642         return ret_conv;
16643 }
16644
16645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16646         if ((_res & 1) != 0) return;
16647         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16648         CHECK_ACCESS(_res_ptr);
16649         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
16650         FREE((void*)_res);
16651         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
16652 }
16653
16654 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
16655         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16656         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
16657         return (int64_t)ret_conv;
16658 }
16659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16660         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
16661         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
16662         return ret_conv;
16663 }
16664
16665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16666         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
16667         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16668         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
16669         return (int64_t)ret_conv;
16670 }
16671
16672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16673         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16674         CHECK_ACCESS(o_ptr);
16675         LDKHTLCDestination o_conv = *(LDKHTLCDestination*)(o_ptr);
16676         o_conv = HTLCDestination_clone((LDKHTLCDestination*)(((uintptr_t)o) & ~1));
16677         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
16678         *ret_copy = COption_HTLCDestinationZ_some(o_conv);
16679         int64_t ret_ref = (uintptr_t)ret_copy;
16680         return ret_ref;
16681 }
16682
16683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1none(JNIEnv *env, jclass clz) {
16684         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
16685         *ret_copy = COption_HTLCDestinationZ_none();
16686         int64_t ret_ref = (uintptr_t)ret_copy;
16687         return ret_ref;
16688 }
16689
16690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16691         if ((_res & 1) != 0) return;
16692         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16693         CHECK_ACCESS(_res_ptr);
16694         LDKCOption_HTLCDestinationZ _res_conv = *(LDKCOption_HTLCDestinationZ*)(_res_ptr);
16695         FREE((void*)_res);
16696         COption_HTLCDestinationZ_free(_res_conv);
16697 }
16698
16699 static inline uintptr_t COption_HTLCDestinationZ_clone_ptr(LDKCOption_HTLCDestinationZ *NONNULL_PTR arg) {
16700         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
16701         *ret_copy = COption_HTLCDestinationZ_clone(arg);
16702 int64_t ret_ref = (uintptr_t)ret_copy;
16703         return ret_ref;
16704 }
16705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16706         LDKCOption_HTLCDestinationZ* arg_conv = (LDKCOption_HTLCDestinationZ*)arg;
16707         int64_t ret_conv = COption_HTLCDestinationZ_clone_ptr(arg_conv);
16708         return ret_conv;
16709 }
16710
16711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16712         LDKCOption_HTLCDestinationZ* orig_conv = (LDKCOption_HTLCDestinationZ*)orig;
16713         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
16714         *ret_copy = COption_HTLCDestinationZ_clone(orig_conv);
16715         int64_t ret_ref = (uintptr_t)ret_copy;
16716         return ret_ref;
16717 }
16718
16719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16720         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16721         CHECK_ACCESS(o_ptr);
16722         LDKCOption_HTLCDestinationZ o_conv = *(LDKCOption_HTLCDestinationZ*)(o_ptr);
16723         o_conv = COption_HTLCDestinationZ_clone((LDKCOption_HTLCDestinationZ*)(((uintptr_t)o) & ~1));
16724         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
16725         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o_conv);
16726         return (int64_t)ret_conv;
16727 }
16728
16729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16730         LDKDecodeError e_conv;
16731         e_conv.inner = (void*)(e & (~1));
16732         e_conv.is_owned = (e & 1) || (e == 0);
16733         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16734         e_conv = DecodeError_clone(&e_conv);
16735         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
16736         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_err(e_conv);
16737         return (int64_t)ret_conv;
16738 }
16739
16740 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16741         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* o_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(o & ~1);
16742         jboolean ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o_conv);
16743         return ret_conv;
16744 }
16745
16746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16747         if ((_res & 1) != 0) return;
16748         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16749         CHECK_ACCESS(_res_ptr);
16750         LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res_conv = *(LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(_res_ptr);
16751         FREE((void*)_res);
16752         CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res_conv);
16753 }
16754
16755 static inline uintptr_t CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR arg) {
16756         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
16757         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(arg);
16758         return (int64_t)ret_conv;
16759 }
16760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16761         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* arg_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(arg & ~1);
16762         int64_t ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(arg_conv);
16763         return ret_conv;
16764 }
16765
16766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16767         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* orig_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(orig & ~1);
16768         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
16769         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig_conv);
16770         return (int64_t)ret_conv;
16771 }
16772
16773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16774         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16775         CHECK_ACCESS(o_ptr);
16776         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
16777         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
16778         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16779         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
16780         int64_t ret_ref = (uintptr_t)ret_copy;
16781         return ret_ref;
16782 }
16783
16784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
16785         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16786         *ret_copy = COption_NetworkUpdateZ_none();
16787         int64_t ret_ref = (uintptr_t)ret_copy;
16788         return ret_ref;
16789 }
16790
16791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16792         if ((_res & 1) != 0) return;
16793         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16794         CHECK_ACCESS(_res_ptr);
16795         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
16796         FREE((void*)_res);
16797         COption_NetworkUpdateZ_free(_res_conv);
16798 }
16799
16800 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
16801         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16802         *ret_copy = COption_NetworkUpdateZ_clone(arg);
16803 int64_t ret_ref = (uintptr_t)ret_copy;
16804         return ret_ref;
16805 }
16806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16807         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
16808         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
16809         return ret_conv;
16810 }
16811
16812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16813         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
16814         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16815         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
16816         int64_t ret_ref = (uintptr_t)ret_copy;
16817         return ret_ref;
16818 }
16819
16820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16821         LDKCVec_SpendableOutputDescriptorZ _res_constr;
16822         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16823         if (_res_constr.datalen > 0)
16824                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16825         else
16826                 _res_constr.data = NULL;
16827         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16828         for (size_t b = 0; b < _res_constr.datalen; b++) {
16829                 int64_t _res_conv_27 = _res_vals[b];
16830                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
16831                 CHECK_ACCESS(_res_conv_27_ptr);
16832                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
16833                 FREE((void*)_res_conv_27);
16834                 _res_constr.data[b] = _res_conv_27_conv;
16835         }
16836         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16837         CVec_SpendableOutputDescriptorZ_free(_res_constr);
16838 }
16839
16840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16841         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16842         CHECK_ACCESS(o_ptr);
16843         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
16844         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
16845         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16846         *ret_copy = COption_EventZ_some(o_conv);
16847         int64_t ret_ref = (uintptr_t)ret_copy;
16848         return ret_ref;
16849 }
16850
16851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
16852         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16853         *ret_copy = COption_EventZ_none();
16854         int64_t ret_ref = (uintptr_t)ret_copy;
16855         return ret_ref;
16856 }
16857
16858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16859         if ((_res & 1) != 0) return;
16860         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16861         CHECK_ACCESS(_res_ptr);
16862         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
16863         FREE((void*)_res);
16864         COption_EventZ_free(_res_conv);
16865 }
16866
16867 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
16868         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16869         *ret_copy = COption_EventZ_clone(arg);
16870 int64_t ret_ref = (uintptr_t)ret_copy;
16871         return ret_ref;
16872 }
16873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16874         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
16875         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
16876         return ret_conv;
16877 }
16878
16879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16880         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
16881         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16882         *ret_copy = COption_EventZ_clone(orig_conv);
16883         int64_t ret_ref = (uintptr_t)ret_copy;
16884         return ret_ref;
16885 }
16886
16887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16888         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16889         CHECK_ACCESS(o_ptr);
16890         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
16891         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
16892         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16893         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
16894         return (int64_t)ret_conv;
16895 }
16896
16897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16898         LDKDecodeError e_conv;
16899         e_conv.inner = (void*)(e & (~1));
16900         e_conv.is_owned = (e & 1) || (e == 0);
16901         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16902         e_conv = DecodeError_clone(&e_conv);
16903         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16904         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
16905         return (int64_t)ret_conv;
16906 }
16907
16908 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16909         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
16910         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
16911         return ret_conv;
16912 }
16913
16914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16915         if ((_res & 1) != 0) return;
16916         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16917         CHECK_ACCESS(_res_ptr);
16918         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
16919         FREE((void*)_res);
16920         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
16921 }
16922
16923 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
16924         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16925         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
16926         return (int64_t)ret_conv;
16927 }
16928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16929         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
16930         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
16931         return ret_conv;
16932 }
16933
16934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16935         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
16936         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16937         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
16938         return (int64_t)ret_conv;
16939 }
16940
16941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16942         LDKCVec_MessageSendEventZ _res_constr;
16943         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16944         if (_res_constr.datalen > 0)
16945                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
16946         else
16947                 _res_constr.data = NULL;
16948         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16949         for (size_t s = 0; s < _res_constr.datalen; s++) {
16950                 int64_t _res_conv_18 = _res_vals[s];
16951                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
16952                 CHECK_ACCESS(_res_conv_18_ptr);
16953                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
16954                 FREE((void*)_res_conv_18);
16955                 _res_constr.data[s] = _res_conv_18_conv;
16956         }
16957         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16958         CVec_MessageSendEventZ_free(_res_constr);
16959 }
16960
16961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16962         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16963         CHECK_ACCESS(o_ptr);
16964         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
16965         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
16966         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16967         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
16968         return (int64_t)ret_conv;
16969 }
16970
16971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
16972         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
16973         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16974         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
16975         return (int64_t)ret_conv;
16976 }
16977
16978 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16979         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
16980         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
16981         return ret_conv;
16982 }
16983
16984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16985         if ((_res & 1) != 0) return;
16986         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16987         CHECK_ACCESS(_res_ptr);
16988         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
16989         FREE((void*)_res);
16990         CResult_TxOutAccessErrorZ_free(_res_conv);
16991 }
16992
16993 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
16994         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16995         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
16996         return (int64_t)ret_conv;
16997 }
16998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16999         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
17000         int64_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
17001         return ret_conv;
17002 }
17003
17004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17005         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
17006         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
17007         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
17008         return (int64_t)ret_conv;
17009 }
17010
17011 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
17012         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
17013         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
17014         return ((int64_t)ret_conv);
17015 }
17016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17017         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
17018         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
17019         return ret_conv;
17020 }
17021
17022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17023         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
17024         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
17025         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
17026         return ((int64_t)ret_conv);
17027 }
17028
17029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
17030         LDKTransaction b_ref;
17031         b_ref.datalen = (*env)->GetArrayLength(env, b);
17032         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
17033         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
17034         b_ref.data_is_owned = true;
17035         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
17036         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
17037         return ((int64_t)ret_conv);
17038 }
17039
17040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17041         if ((_res & 1) != 0) return;
17042         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17043         CHECK_ACCESS(_res_ptr);
17044         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
17045         FREE((void*)_res);
17046         C2Tuple_usizeTransactionZ_free(_res_conv);
17047 }
17048
17049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17050         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
17051         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17052         if (_res_constr.datalen > 0)
17053                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
17054         else
17055                 _res_constr.data = NULL;
17056         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17057         for (size_t c = 0; c < _res_constr.datalen; c++) {
17058                 int64_t _res_conv_28 = _res_vals[c];
17059                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
17060                 CHECK_ACCESS(_res_conv_28_ptr);
17061                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
17062                 FREE((void*)_res_conv_28);
17063                 _res_constr.data[c] = _res_conv_28_conv;
17064         }
17065         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17066         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
17067 }
17068
17069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17070         LDKCVec_TxidZ _res_constr;
17071         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17072         if (_res_constr.datalen > 0)
17073                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
17074         else
17075                 _res_constr.data = NULL;
17076         for (size_t i = 0; i < _res_constr.datalen; i++) {
17077                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
17078                 LDKThirtyTwoBytes _res_conv_8_ref;
17079                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
17080                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
17081                 _res_constr.data[i] = _res_conv_8_ref;
17082         }
17083         CVec_TxidZ_free(_res_constr);
17084 }
17085
17086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
17087         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
17088         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
17089         return (int64_t)ret_conv;
17090 }
17091
17092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
17093         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
17094         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
17095         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
17096         return (int64_t)ret_conv;
17097 }
17098
17099 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17100         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
17101         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
17102         return ret_conv;
17103 }
17104
17105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17106         if ((_res & 1) != 0) return;
17107         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17108         CHECK_ACCESS(_res_ptr);
17109         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
17110         FREE((void*)_res);
17111         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
17112 }
17113
17114 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
17115         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
17116         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
17117         return (int64_t)ret_conv;
17118 }
17119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17120         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
17121         int64_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
17122         return ret_conv;
17123 }
17124
17125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17126         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
17127         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
17128         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
17129         return (int64_t)ret_conv;
17130 }
17131
17132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17133         LDKCVec_MonitorEventZ _res_constr;
17134         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17135         if (_res_constr.datalen > 0)
17136                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
17137         else
17138                 _res_constr.data = NULL;
17139         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17140         for (size_t o = 0; o < _res_constr.datalen; o++) {
17141                 int64_t _res_conv_14 = _res_vals[o];
17142                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
17143                 CHECK_ACCESS(_res_conv_14_ptr);
17144                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
17145                 FREE((void*)_res_conv_14);
17146                 _res_constr.data[o] = _res_conv_14_conv;
17147         }
17148         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17149         CVec_MonitorEventZ_free(_res_constr);
17150 }
17151
17152 static inline uintptr_t C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR arg) {
17153         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
17154         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(arg);
17155         return ((int64_t)ret_conv);
17156 }
17157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17158         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* arg_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(arg & ~1);
17159         int64_t ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(arg_conv);
17160         return ret_conv;
17161 }
17162
17163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17164         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* orig_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(orig & ~1);
17165         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
17166         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig_conv);
17167         return ((int64_t)ret_conv);
17168 }
17169
17170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_tArray b, int8_tArray c) {
17171         LDKOutPoint a_conv;
17172         a_conv.inner = (void*)(a & (~1));
17173         a_conv.is_owned = (a & 1) || (a == 0);
17174         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17175         a_conv = OutPoint_clone(&a_conv);
17176         LDKCVec_MonitorEventZ b_constr;
17177         b_constr.datalen = (*env)->GetArrayLength(env, b);
17178         if (b_constr.datalen > 0)
17179                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
17180         else
17181                 b_constr.data = NULL;
17182         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
17183         for (size_t o = 0; o < b_constr.datalen; o++) {
17184                 int64_t b_conv_14 = b_vals[o];
17185                 void* b_conv_14_ptr = (void*)(((uintptr_t)b_conv_14) & ~1);
17186                 CHECK_ACCESS(b_conv_14_ptr);
17187                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
17188                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)b_conv_14) & ~1));
17189                 b_constr.data[o] = b_conv_14_conv;
17190         }
17191         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
17192         LDKPublicKey c_ref;
17193         CHECK((*env)->GetArrayLength(env, c) == 33);
17194         (*env)->GetByteArrayRegion(env, c, 0, 33, c_ref.compressed_form);
17195         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
17196         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a_conv, b_constr, c_ref);
17197         return ((int64_t)ret_conv);
17198 }
17199
17200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17201         if ((_res & 1) != 0) return;
17202         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17203         CHECK_ACCESS(_res_ptr);
17204         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_ptr);
17205         FREE((void*)_res);
17206         C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res_conv);
17207 }
17208
17209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17210         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res_constr;
17211         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17212         if (_res_constr.datalen > 0)
17213                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
17214         else
17215                 _res_constr.data = NULL;
17216         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17217         for (size_t x = 0; x < _res_constr.datalen; x++) {
17218                 int64_t _res_conv_49 = _res_vals[x];
17219                 void* _res_conv_49_ptr = (void*)(((uintptr_t)_res_conv_49) & ~1);
17220                 CHECK_ACCESS(_res_conv_49_ptr);
17221                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_conv_49_ptr);
17222                 FREE((void*)_res_conv_49);
17223                 _res_constr.data[x] = _res_conv_49_conv;
17224         }
17225         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17226         CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res_constr);
17227 }
17228
17229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17230         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17231         CHECK_ACCESS(o_ptr);
17232         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
17233         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
17234         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
17235         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
17236         int64_t ret_ref = (uintptr_t)ret_copy;
17237         return ret_ref;
17238 }
17239
17240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
17241         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
17242         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
17243         int64_t ret_ref = (uintptr_t)ret_copy;
17244         return ret_ref;
17245 }
17246
17247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17248         if ((_res & 1) != 0) return;
17249         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17250         CHECK_ACCESS(_res_ptr);
17251         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
17252         FREE((void*)_res);
17253         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
17254 }
17255
17256 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
17257         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
17258         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
17259 int64_t ret_ref = (uintptr_t)ret_copy;
17260         return ret_ref;
17261 }
17262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17263         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
17264         int64_t ret_conv = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
17265         return ret_conv;
17266 }
17267
17268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17269         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
17270         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
17271         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
17272         int64_t ret_ref = (uintptr_t)ret_copy;
17273         return ret_ref;
17274 }
17275
17276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17277         LDKFixedPenaltyScorer o_conv;
17278         o_conv.inner = (void*)(o & (~1));
17279         o_conv.is_owned = (o & 1) || (o == 0);
17280         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17281         o_conv = FixedPenaltyScorer_clone(&o_conv);
17282         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17283         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
17284         return (int64_t)ret_conv;
17285 }
17286
17287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17288         LDKDecodeError e_conv;
17289         e_conv.inner = (void*)(e & (~1));
17290         e_conv.is_owned = (e & 1) || (e == 0);
17291         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17292         e_conv = DecodeError_clone(&e_conv);
17293         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17294         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
17295         return (int64_t)ret_conv;
17296 }
17297
17298 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17299         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
17300         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
17301         return ret_conv;
17302 }
17303
17304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17305         if ((_res & 1) != 0) return;
17306         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17307         CHECK_ACCESS(_res_ptr);
17308         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
17309         FREE((void*)_res);
17310         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
17311 }
17312
17313 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
17314         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17315         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
17316         return (int64_t)ret_conv;
17317 }
17318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17319         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
17320         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
17321         return ret_conv;
17322 }
17323
17324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17325         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
17326         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17327         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
17328         return (int64_t)ret_conv;
17329 }
17330
17331 static inline uintptr_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
17332         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
17333         *ret_conv = C2Tuple_u64u64Z_clone(arg);
17334         return ((int64_t)ret_conv);
17335 }
17336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17337         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)(arg & ~1);
17338         int64_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
17339         return ret_conv;
17340 }
17341
17342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17343         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)(orig & ~1);
17344         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
17345         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
17346         return ((int64_t)ret_conv);
17347 }
17348
17349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
17350         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
17351         *ret_conv = C2Tuple_u64u64Z_new(a, b);
17352         return ((int64_t)ret_conv);
17353 }
17354
17355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
17356         if ((_res & 1) != 0) return;
17357         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17358         CHECK_ACCESS(_res_ptr);
17359         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
17360         FREE((void*)_res);
17361         C2Tuple_u64u64Z_free(_res_conv);
17362 }
17363
17364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17365         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17366         CHECK_ACCESS(o_ptr);
17367         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
17368         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)(((uintptr_t)o) & ~1));
17369         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17370         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
17371         int64_t ret_ref = (uintptr_t)ret_copy;
17372         return ret_ref;
17373 }
17374
17375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1none(JNIEnv *env, jclass clz) {
17376         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17377         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
17378         int64_t ret_ref = (uintptr_t)ret_copy;
17379         return ret_ref;
17380 }
17381
17382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17383         if ((_res & 1) != 0) return;
17384         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17385         CHECK_ACCESS(_res_ptr);
17386         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
17387         FREE((void*)_res);
17388         COption_C2Tuple_u64u64ZZ_free(_res_conv);
17389 }
17390
17391 static inline uintptr_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
17392         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17393         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
17394 int64_t ret_ref = (uintptr_t)ret_copy;
17395         return ret_ref;
17396 }
17397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17398         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)arg;
17399         int64_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
17400         return ret_conv;
17401 }
17402
17403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17404         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)orig;
17405         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17406         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
17407         int64_t ret_ref = (uintptr_t)ret_copy;
17408         return ret_ref;
17409 }
17410
17411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17412         LDKCVec_NodeIdZ _res_constr;
17413         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17414         if (_res_constr.datalen > 0)
17415                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
17416         else
17417                 _res_constr.data = NULL;
17418         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17419         for (size_t i = 0; i < _res_constr.datalen; i++) {
17420                 int64_t _res_conv_8 = _res_vals[i];
17421                 LDKNodeId _res_conv_8_conv;
17422                 _res_conv_8_conv.inner = (void*)(_res_conv_8 & (~1));
17423                 _res_conv_8_conv.is_owned = (_res_conv_8 & 1) || (_res_conv_8 == 0);
17424                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
17425                 _res_constr.data[i] = _res_conv_8_conv;
17426         }
17427         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17428         CVec_NodeIdZ_free(_res_constr);
17429 }
17430
17431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17432         LDKProbabilisticScorer o_conv;
17433         o_conv.inner = (void*)(o & (~1));
17434         o_conv.is_owned = (o & 1) || (o == 0);
17435         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17436         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
17437         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
17438         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
17439         return (int64_t)ret_conv;
17440 }
17441
17442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17443         LDKDecodeError e_conv;
17444         e_conv.inner = (void*)(e & (~1));
17445         e_conv.is_owned = (e & 1) || (e == 0);
17446         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17447         e_conv = DecodeError_clone(&e_conv);
17448         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
17449         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
17450         return (int64_t)ret_conv;
17451 }
17452
17453 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17454         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
17455         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
17456         return ret_conv;
17457 }
17458
17459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17460         if ((_res & 1) != 0) return;
17461         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17462         CHECK_ACCESS(_res_ptr);
17463         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
17464         FREE((void*)_res);
17465         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
17466 }
17467
17468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17469         LDKInitFeatures o_conv;
17470         o_conv.inner = (void*)(o & (~1));
17471         o_conv.is_owned = (o & 1) || (o == 0);
17472         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17473         o_conv = InitFeatures_clone(&o_conv);
17474         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17475         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
17476         return (int64_t)ret_conv;
17477 }
17478
17479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17480         LDKDecodeError e_conv;
17481         e_conv.inner = (void*)(e & (~1));
17482         e_conv.is_owned = (e & 1) || (e == 0);
17483         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17484         e_conv = DecodeError_clone(&e_conv);
17485         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17486         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
17487         return (int64_t)ret_conv;
17488 }
17489
17490 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17491         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
17492         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
17493         return ret_conv;
17494 }
17495
17496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17497         if ((_res & 1) != 0) return;
17498         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17499         CHECK_ACCESS(_res_ptr);
17500         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
17501         FREE((void*)_res);
17502         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
17503 }
17504
17505 static inline uintptr_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17506         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17507         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
17508         return (int64_t)ret_conv;
17509 }
17510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17511         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
17512         int64_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17513         return ret_conv;
17514 }
17515
17516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17517         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(orig & ~1);
17518         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17519         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
17520         return (int64_t)ret_conv;
17521 }
17522
17523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17524         LDKChannelFeatures o_conv;
17525         o_conv.inner = (void*)(o & (~1));
17526         o_conv.is_owned = (o & 1) || (o == 0);
17527         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17528         o_conv = ChannelFeatures_clone(&o_conv);
17529         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17530         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
17531         return (int64_t)ret_conv;
17532 }
17533
17534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17535         LDKDecodeError e_conv;
17536         e_conv.inner = (void*)(e & (~1));
17537         e_conv.is_owned = (e & 1) || (e == 0);
17538         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17539         e_conv = DecodeError_clone(&e_conv);
17540         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17541         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
17542         return (int64_t)ret_conv;
17543 }
17544
17545 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17546         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
17547         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
17548         return ret_conv;
17549 }
17550
17551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17552         if ((_res & 1) != 0) return;
17553         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17554         CHECK_ACCESS(_res_ptr);
17555         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
17556         FREE((void*)_res);
17557         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
17558 }
17559
17560 static inline uintptr_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17561         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17562         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
17563         return (int64_t)ret_conv;
17564 }
17565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17566         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
17567         int64_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17568         return ret_conv;
17569 }
17570
17571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17572         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(orig & ~1);
17573         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17574         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
17575         return (int64_t)ret_conv;
17576 }
17577
17578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17579         LDKNodeFeatures o_conv;
17580         o_conv.inner = (void*)(o & (~1));
17581         o_conv.is_owned = (o & 1) || (o == 0);
17582         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17583         o_conv = NodeFeatures_clone(&o_conv);
17584         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17585         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
17586         return (int64_t)ret_conv;
17587 }
17588
17589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17590         LDKDecodeError e_conv;
17591         e_conv.inner = (void*)(e & (~1));
17592         e_conv.is_owned = (e & 1) || (e == 0);
17593         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17594         e_conv = DecodeError_clone(&e_conv);
17595         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17596         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
17597         return (int64_t)ret_conv;
17598 }
17599
17600 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17601         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
17602         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
17603         return ret_conv;
17604 }
17605
17606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17607         if ((_res & 1) != 0) return;
17608         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17609         CHECK_ACCESS(_res_ptr);
17610         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
17611         FREE((void*)_res);
17612         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
17613 }
17614
17615 static inline uintptr_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17616         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17617         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
17618         return (int64_t)ret_conv;
17619 }
17620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17621         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
17622         int64_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17623         return ret_conv;
17624 }
17625
17626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17627         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(orig & ~1);
17628         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17629         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
17630         return (int64_t)ret_conv;
17631 }
17632
17633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17634         LDKInvoiceFeatures o_conv;
17635         o_conv.inner = (void*)(o & (~1));
17636         o_conv.is_owned = (o & 1) || (o == 0);
17637         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17638         o_conv = InvoiceFeatures_clone(&o_conv);
17639         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17640         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
17641         return (int64_t)ret_conv;
17642 }
17643
17644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17645         LDKDecodeError e_conv;
17646         e_conv.inner = (void*)(e & (~1));
17647         e_conv.is_owned = (e & 1) || (e == 0);
17648         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17649         e_conv = DecodeError_clone(&e_conv);
17650         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17651         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
17652         return (int64_t)ret_conv;
17653 }
17654
17655 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17656         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
17657         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
17658         return ret_conv;
17659 }
17660
17661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17662         if ((_res & 1) != 0) return;
17663         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17664         CHECK_ACCESS(_res_ptr);
17665         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
17666         FREE((void*)_res);
17667         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
17668 }
17669
17670 static inline uintptr_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17671         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17672         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
17673         return (int64_t)ret_conv;
17674 }
17675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17676         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
17677         int64_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17678         return ret_conv;
17679 }
17680
17681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17682         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(orig & ~1);
17683         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17684         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
17685         return (int64_t)ret_conv;
17686 }
17687
17688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17689         LDKChannelTypeFeatures o_conv;
17690         o_conv.inner = (void*)(o & (~1));
17691         o_conv.is_owned = (o & 1) || (o == 0);
17692         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17693         o_conv = ChannelTypeFeatures_clone(&o_conv);
17694         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17695         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
17696         return (int64_t)ret_conv;
17697 }
17698
17699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17700         LDKDecodeError e_conv;
17701         e_conv.inner = (void*)(e & (~1));
17702         e_conv.is_owned = (e & 1) || (e == 0);
17703         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17704         e_conv = DecodeError_clone(&e_conv);
17705         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17706         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
17707         return (int64_t)ret_conv;
17708 }
17709
17710 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17711         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
17712         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
17713         return ret_conv;
17714 }
17715
17716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17717         if ((_res & 1) != 0) return;
17718         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17719         CHECK_ACCESS(_res_ptr);
17720         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
17721         FREE((void*)_res);
17722         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
17723 }
17724
17725 static inline uintptr_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17726         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17727         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
17728         return (int64_t)ret_conv;
17729 }
17730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17731         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(arg & ~1);
17732         int64_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17733         return ret_conv;
17734 }
17735
17736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17737         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(orig & ~1);
17738         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17739         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
17740         return (int64_t)ret_conv;
17741 }
17742
17743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17744         LDKNodeId o_conv;
17745         o_conv.inner = (void*)(o & (~1));
17746         o_conv.is_owned = (o & 1) || (o == 0);
17747         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17748         o_conv = NodeId_clone(&o_conv);
17749         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17750         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
17751         return (int64_t)ret_conv;
17752 }
17753
17754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17755         LDKDecodeError e_conv;
17756         e_conv.inner = (void*)(e & (~1));
17757         e_conv.is_owned = (e & 1) || (e == 0);
17758         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17759         e_conv = DecodeError_clone(&e_conv);
17760         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17761         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
17762         return (int64_t)ret_conv;
17763 }
17764
17765 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17766         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
17767         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
17768         return ret_conv;
17769 }
17770
17771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17772         if ((_res & 1) != 0) return;
17773         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17774         CHECK_ACCESS(_res_ptr);
17775         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
17776         FREE((void*)_res);
17777         CResult_NodeIdDecodeErrorZ_free(_res_conv);
17778 }
17779
17780 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
17781         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17782         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
17783         return (int64_t)ret_conv;
17784 }
17785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17786         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
17787         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
17788         return ret_conv;
17789 }
17790
17791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17792         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
17793         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17794         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
17795         return (int64_t)ret_conv;
17796 }
17797
17798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17799         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17800         CHECK_ACCESS(o_ptr);
17801         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
17802         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
17803         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17804         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
17805         return (int64_t)ret_conv;
17806 }
17807
17808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17809         LDKDecodeError e_conv;
17810         e_conv.inner = (void*)(e & (~1));
17811         e_conv.is_owned = (e & 1) || (e == 0);
17812         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17813         e_conv = DecodeError_clone(&e_conv);
17814         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17815         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
17816         return (int64_t)ret_conv;
17817 }
17818
17819 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17820         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
17821         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
17822         return ret_conv;
17823 }
17824
17825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17826         if ((_res & 1) != 0) return;
17827         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17828         CHECK_ACCESS(_res_ptr);
17829         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
17830         FREE((void*)_res);
17831         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
17832 }
17833
17834 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
17835         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17836         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
17837         return (int64_t)ret_conv;
17838 }
17839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17840         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
17841         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
17842         return ret_conv;
17843 }
17844
17845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17846         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
17847         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17848         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
17849         return (int64_t)ret_conv;
17850 }
17851
17852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17853         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17854         CHECK_ACCESS(o_ptr);
17855         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
17856         if (o_conv.free == LDKAccess_JCalls_free) {
17857                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17858                 LDKAccess_JCalls_cloned(&o_conv);
17859         }
17860         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
17861         *ret_copy = COption_AccessZ_some(o_conv);
17862         int64_t ret_ref = (uintptr_t)ret_copy;
17863         return ret_ref;
17864 }
17865
17866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
17867         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
17868         *ret_copy = COption_AccessZ_none();
17869         int64_t ret_ref = (uintptr_t)ret_copy;
17870         return ret_ref;
17871 }
17872
17873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17874         if ((_res & 1) != 0) return;
17875         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17876         CHECK_ACCESS(_res_ptr);
17877         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
17878         FREE((void*)_res);
17879         COption_AccessZ_free(_res_conv);
17880 }
17881
17882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
17883         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17884         *ret_conv = CResult_boolLightningErrorZ_ok(o);
17885         return (int64_t)ret_conv;
17886 }
17887
17888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17889         LDKLightningError e_conv;
17890         e_conv.inner = (void*)(e & (~1));
17891         e_conv.is_owned = (e & 1) || (e == 0);
17892         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17893         e_conv = LightningError_clone(&e_conv);
17894         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17895         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
17896         return (int64_t)ret_conv;
17897 }
17898
17899 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17900         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
17901         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
17902         return ret_conv;
17903 }
17904
17905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17906         if ((_res & 1) != 0) return;
17907         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17908         CHECK_ACCESS(_res_ptr);
17909         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
17910         FREE((void*)_res);
17911         CResult_boolLightningErrorZ_free(_res_conv);
17912 }
17913
17914 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
17915         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17916         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
17917         return (int64_t)ret_conv;
17918 }
17919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17920         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
17921         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
17922         return ret_conv;
17923 }
17924
17925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17926         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
17927         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17928         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
17929         return (int64_t)ret_conv;
17930 }
17931
17932 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
17933         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17934         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
17935         return ((int64_t)ret_conv);
17936 }
17937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17938         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
17939         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
17940         return ret_conv;
17941 }
17942
17943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17944         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
17945         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17946         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
17947         return ((int64_t)ret_conv);
17948 }
17949
17950 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) {
17951         LDKChannelAnnouncement a_conv;
17952         a_conv.inner = (void*)(a & (~1));
17953         a_conv.is_owned = (a & 1) || (a == 0);
17954         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17955         a_conv = ChannelAnnouncement_clone(&a_conv);
17956         LDKChannelUpdate b_conv;
17957         b_conv.inner = (void*)(b & (~1));
17958         b_conv.is_owned = (b & 1) || (b == 0);
17959         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
17960         b_conv = ChannelUpdate_clone(&b_conv);
17961         LDKChannelUpdate c_conv;
17962         c_conv.inner = (void*)(c & (~1));
17963         c_conv.is_owned = (c & 1) || (c == 0);
17964         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
17965         c_conv = ChannelUpdate_clone(&c_conv);
17966         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17967         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
17968         return ((int64_t)ret_conv);
17969 }
17970
17971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17972         if ((_res & 1) != 0) return;
17973         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17974         CHECK_ACCESS(_res_ptr);
17975         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
17976         FREE((void*)_res);
17977         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
17978 }
17979
17980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17981         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
17982         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17983         if (_res_constr.datalen > 0)
17984                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
17985         else
17986                 _res_constr.data = NULL;
17987         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17988         for (size_t h = 0; h < _res_constr.datalen; h++) {
17989                 int64_t _res_conv_59 = _res_vals[h];
17990                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
17991                 CHECK_ACCESS(_res_conv_59_ptr);
17992                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
17993                 FREE((void*)_res_conv_59);
17994                 _res_constr.data[h] = _res_conv_59_conv;
17995         }
17996         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17997         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
17998 }
17999
18000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18001         LDKCVec_NodeAnnouncementZ _res_constr;
18002         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18003         if (_res_constr.datalen > 0)
18004                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
18005         else
18006                 _res_constr.data = NULL;
18007         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18008         for (size_t s = 0; s < _res_constr.datalen; s++) {
18009                 int64_t _res_conv_18 = _res_vals[s];
18010                 LDKNodeAnnouncement _res_conv_18_conv;
18011                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
18012                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
18013                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
18014                 _res_constr.data[s] = _res_conv_18_conv;
18015         }
18016         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18017         CVec_NodeAnnouncementZ_free(_res_constr);
18018 }
18019
18020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
18021         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18022         *ret_conv = CResult_NoneLightningErrorZ_ok();
18023         return (int64_t)ret_conv;
18024 }
18025
18026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18027         LDKLightningError e_conv;
18028         e_conv.inner = (void*)(e & (~1));
18029         e_conv.is_owned = (e & 1) || (e == 0);
18030         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18031         e_conv = LightningError_clone(&e_conv);
18032         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18033         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
18034         return (int64_t)ret_conv;
18035 }
18036
18037 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18038         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
18039         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
18040         return ret_conv;
18041 }
18042
18043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18044         if ((_res & 1) != 0) return;
18045         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18046         CHECK_ACCESS(_res_ptr);
18047         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
18048         FREE((void*)_res);
18049         CResult_NoneLightningErrorZ_free(_res_conv);
18050 }
18051
18052 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
18053         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18054         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
18055         return (int64_t)ret_conv;
18056 }
18057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18058         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
18059         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
18060         return ret_conv;
18061 }
18062
18063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18064         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
18065         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18066         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
18067         return (int64_t)ret_conv;
18068 }
18069
18070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18071         LDKChannelUpdateInfo o_conv;
18072         o_conv.inner = (void*)(o & (~1));
18073         o_conv.is_owned = (o & 1) || (o == 0);
18074         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18075         o_conv = ChannelUpdateInfo_clone(&o_conv);
18076         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18077         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
18078         return (int64_t)ret_conv;
18079 }
18080
18081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18082         LDKDecodeError e_conv;
18083         e_conv.inner = (void*)(e & (~1));
18084         e_conv.is_owned = (e & 1) || (e == 0);
18085         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18086         e_conv = DecodeError_clone(&e_conv);
18087         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18088         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
18089         return (int64_t)ret_conv;
18090 }
18091
18092 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18093         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
18094         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
18095         return ret_conv;
18096 }
18097
18098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18099         if ((_res & 1) != 0) return;
18100         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18101         CHECK_ACCESS(_res_ptr);
18102         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
18103         FREE((void*)_res);
18104         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
18105 }
18106
18107 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
18108         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18109         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
18110         return (int64_t)ret_conv;
18111 }
18112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18113         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
18114         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
18115         return ret_conv;
18116 }
18117
18118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18119         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
18120         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18121         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
18122         return (int64_t)ret_conv;
18123 }
18124
18125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18126         LDKChannelInfo o_conv;
18127         o_conv.inner = (void*)(o & (~1));
18128         o_conv.is_owned = (o & 1) || (o == 0);
18129         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18130         o_conv = ChannelInfo_clone(&o_conv);
18131         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18132         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
18133         return (int64_t)ret_conv;
18134 }
18135
18136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18137         LDKDecodeError e_conv;
18138         e_conv.inner = (void*)(e & (~1));
18139         e_conv.is_owned = (e & 1) || (e == 0);
18140         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18141         e_conv = DecodeError_clone(&e_conv);
18142         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18143         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
18144         return (int64_t)ret_conv;
18145 }
18146
18147 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18148         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
18149         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
18150         return ret_conv;
18151 }
18152
18153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18154         if ((_res & 1) != 0) return;
18155         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18156         CHECK_ACCESS(_res_ptr);
18157         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
18158         FREE((void*)_res);
18159         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
18160 }
18161
18162 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
18163         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18164         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
18165         return (int64_t)ret_conv;
18166 }
18167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18168         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
18169         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
18170         return ret_conv;
18171 }
18172
18173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18174         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
18175         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18176         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
18177         return (int64_t)ret_conv;
18178 }
18179
18180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18181         LDKRoutingFees o_conv;
18182         o_conv.inner = (void*)(o & (~1));
18183         o_conv.is_owned = (o & 1) || (o == 0);
18184         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18185         o_conv = RoutingFees_clone(&o_conv);
18186         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18187         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
18188         return (int64_t)ret_conv;
18189 }
18190
18191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18192         LDKDecodeError e_conv;
18193         e_conv.inner = (void*)(e & (~1));
18194         e_conv.is_owned = (e & 1) || (e == 0);
18195         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18196         e_conv = DecodeError_clone(&e_conv);
18197         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18198         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
18199         return (int64_t)ret_conv;
18200 }
18201
18202 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18203         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
18204         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
18205         return ret_conv;
18206 }
18207
18208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18209         if ((_res & 1) != 0) return;
18210         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18211         CHECK_ACCESS(_res_ptr);
18212         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
18213         FREE((void*)_res);
18214         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
18215 }
18216
18217 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
18218         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18219         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
18220         return (int64_t)ret_conv;
18221 }
18222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18223         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
18224         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
18225         return ret_conv;
18226 }
18227
18228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18229         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
18230         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18231         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
18232         return (int64_t)ret_conv;
18233 }
18234
18235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18236         LDKCVec_NetAddressZ _res_constr;
18237         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18238         if (_res_constr.datalen > 0)
18239                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18240         else
18241                 _res_constr.data = NULL;
18242         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18243         for (size_t m = 0; m < _res_constr.datalen; m++) {
18244                 int64_t _res_conv_12 = _res_vals[m];
18245                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
18246                 CHECK_ACCESS(_res_conv_12_ptr);
18247                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
18248                 FREE((void*)_res_conv_12);
18249                 _res_constr.data[m] = _res_conv_12_conv;
18250         }
18251         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18252         CVec_NetAddressZ_free(_res_constr);
18253 }
18254
18255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18256         LDKNodeAnnouncementInfo o_conv;
18257         o_conv.inner = (void*)(o & (~1));
18258         o_conv.is_owned = (o & 1) || (o == 0);
18259         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18260         o_conv = NodeAnnouncementInfo_clone(&o_conv);
18261         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18262         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
18263         return (int64_t)ret_conv;
18264 }
18265
18266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18267         LDKDecodeError e_conv;
18268         e_conv.inner = (void*)(e & (~1));
18269         e_conv.is_owned = (e & 1) || (e == 0);
18270         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18271         e_conv = DecodeError_clone(&e_conv);
18272         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18273         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
18274         return (int64_t)ret_conv;
18275 }
18276
18277 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18278         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
18279         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
18280         return ret_conv;
18281 }
18282
18283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18284         if ((_res & 1) != 0) return;
18285         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18286         CHECK_ACCESS(_res_ptr);
18287         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
18288         FREE((void*)_res);
18289         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
18290 }
18291
18292 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
18293         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18294         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
18295         return (int64_t)ret_conv;
18296 }
18297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18298         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
18299         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
18300         return ret_conv;
18301 }
18302
18303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18304         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
18305         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18306         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
18307         return (int64_t)ret_conv;
18308 }
18309
18310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18311         LDKNodeAlias o_conv;
18312         o_conv.inner = (void*)(o & (~1));
18313         o_conv.is_owned = (o & 1) || (o == 0);
18314         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18315         o_conv = NodeAlias_clone(&o_conv);
18316         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18317         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
18318         return (int64_t)ret_conv;
18319 }
18320
18321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18322         LDKDecodeError e_conv;
18323         e_conv.inner = (void*)(e & (~1));
18324         e_conv.is_owned = (e & 1) || (e == 0);
18325         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18326         e_conv = DecodeError_clone(&e_conv);
18327         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18328         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
18329         return (int64_t)ret_conv;
18330 }
18331
18332 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18333         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(o & ~1);
18334         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
18335         return ret_conv;
18336 }
18337
18338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18339         if ((_res & 1) != 0) return;
18340         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18341         CHECK_ACCESS(_res_ptr);
18342         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
18343         FREE((void*)_res);
18344         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
18345 }
18346
18347 static inline uintptr_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
18348         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18349         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
18350         return (int64_t)ret_conv;
18351 }
18352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18353         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(arg & ~1);
18354         int64_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
18355         return ret_conv;
18356 }
18357
18358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18359         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(orig & ~1);
18360         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18361         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
18362         return (int64_t)ret_conv;
18363 }
18364
18365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18366         LDKNodeInfo o_conv;
18367         o_conv.inner = (void*)(o & (~1));
18368         o_conv.is_owned = (o & 1) || (o == 0);
18369         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18370         o_conv = NodeInfo_clone(&o_conv);
18371         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18372         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
18373         return (int64_t)ret_conv;
18374 }
18375
18376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18377         LDKDecodeError e_conv;
18378         e_conv.inner = (void*)(e & (~1));
18379         e_conv.is_owned = (e & 1) || (e == 0);
18380         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18381         e_conv = DecodeError_clone(&e_conv);
18382         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18383         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
18384         return (int64_t)ret_conv;
18385 }
18386
18387 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18388         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
18389         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
18390         return ret_conv;
18391 }
18392
18393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18394         if ((_res & 1) != 0) return;
18395         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18396         CHECK_ACCESS(_res_ptr);
18397         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
18398         FREE((void*)_res);
18399         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
18400 }
18401
18402 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
18403         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18404         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
18405         return (int64_t)ret_conv;
18406 }
18407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18408         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
18409         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
18410         return ret_conv;
18411 }
18412
18413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18414         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
18415         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18416         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
18417         return (int64_t)ret_conv;
18418 }
18419
18420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18421         LDKNetworkGraph o_conv;
18422         o_conv.inner = (void*)(o & (~1));
18423         o_conv.is_owned = (o & 1) || (o == 0);
18424         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18425         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
18426         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
18427         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
18428         return (int64_t)ret_conv;
18429 }
18430
18431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18432         LDKDecodeError e_conv;
18433         e_conv.inner = (void*)(e & (~1));
18434         e_conv.is_owned = (e & 1) || (e == 0);
18435         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18436         e_conv = DecodeError_clone(&e_conv);
18437         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
18438         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
18439         return (int64_t)ret_conv;
18440 }
18441
18442 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18443         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
18444         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
18445         return ret_conv;
18446 }
18447
18448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18449         if ((_res & 1) != 0) return;
18450         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18451         CHECK_ACCESS(_res_ptr);
18452         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
18453         FREE((void*)_res);
18454         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
18455 }
18456
18457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
18458         LDKCVec_NetAddressZ o_constr;
18459         o_constr.datalen = (*env)->GetArrayLength(env, o);
18460         if (o_constr.datalen > 0)
18461                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18462         else
18463                 o_constr.data = NULL;
18464         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
18465         for (size_t m = 0; m < o_constr.datalen; m++) {
18466                 int64_t o_conv_12 = o_vals[m];
18467                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
18468                 CHECK_ACCESS(o_conv_12_ptr);
18469                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
18470                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
18471                 o_constr.data[m] = o_conv_12_conv;
18472         }
18473         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
18474         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18475         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
18476         int64_t ret_ref = (uintptr_t)ret_copy;
18477         return ret_ref;
18478 }
18479
18480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
18481         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18482         *ret_copy = COption_CVec_NetAddressZZ_none();
18483         int64_t ret_ref = (uintptr_t)ret_copy;
18484         return ret_ref;
18485 }
18486
18487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18488         if ((_res & 1) != 0) return;
18489         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18490         CHECK_ACCESS(_res_ptr);
18491         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
18492         FREE((void*)_res);
18493         COption_CVec_NetAddressZZ_free(_res_conv);
18494 }
18495
18496 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
18497         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18498         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
18499 int64_t ret_ref = (uintptr_t)ret_copy;
18500         return ret_ref;
18501 }
18502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18503         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
18504         int64_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
18505         return ret_conv;
18506 }
18507
18508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18509         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
18510         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18511         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
18512         int64_t ret_ref = (uintptr_t)ret_copy;
18513         return ret_ref;
18514 }
18515
18516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18517         LDKDelayedPaymentOutputDescriptor o_conv;
18518         o_conv.inner = (void*)(o & (~1));
18519         o_conv.is_owned = (o & 1) || (o == 0);
18520         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18521         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
18522         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18523         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
18524         return (int64_t)ret_conv;
18525 }
18526
18527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18528         LDKDecodeError e_conv;
18529         e_conv.inner = (void*)(e & (~1));
18530         e_conv.is_owned = (e & 1) || (e == 0);
18531         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18532         e_conv = DecodeError_clone(&e_conv);
18533         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18534         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
18535         return (int64_t)ret_conv;
18536 }
18537
18538 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18539         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
18540         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
18541         return ret_conv;
18542 }
18543
18544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18545         if ((_res & 1) != 0) return;
18546         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18547         CHECK_ACCESS(_res_ptr);
18548         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
18549         FREE((void*)_res);
18550         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
18551 }
18552
18553 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
18554         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18555         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
18556         return (int64_t)ret_conv;
18557 }
18558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18559         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
18560         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
18561         return ret_conv;
18562 }
18563
18564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18565         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
18566         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18567         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
18568         return (int64_t)ret_conv;
18569 }
18570
18571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18572         LDKStaticPaymentOutputDescriptor o_conv;
18573         o_conv.inner = (void*)(o & (~1));
18574         o_conv.is_owned = (o & 1) || (o == 0);
18575         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18576         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
18577         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18578         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
18579         return (int64_t)ret_conv;
18580 }
18581
18582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18583         LDKDecodeError e_conv;
18584         e_conv.inner = (void*)(e & (~1));
18585         e_conv.is_owned = (e & 1) || (e == 0);
18586         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18587         e_conv = DecodeError_clone(&e_conv);
18588         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18589         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
18590         return (int64_t)ret_conv;
18591 }
18592
18593 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18594         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
18595         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
18596         return ret_conv;
18597 }
18598
18599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18600         if ((_res & 1) != 0) return;
18601         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18602         CHECK_ACCESS(_res_ptr);
18603         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
18604         FREE((void*)_res);
18605         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
18606 }
18607
18608 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
18609         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18610         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
18611         return (int64_t)ret_conv;
18612 }
18613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18614         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
18615         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
18616         return ret_conv;
18617 }
18618
18619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18620         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
18621         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18622         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
18623         return (int64_t)ret_conv;
18624 }
18625
18626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18627         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18628         CHECK_ACCESS(o_ptr);
18629         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
18630         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
18631         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18632         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
18633         return (int64_t)ret_conv;
18634 }
18635
18636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18637         LDKDecodeError e_conv;
18638         e_conv.inner = (void*)(e & (~1));
18639         e_conv.is_owned = (e & 1) || (e == 0);
18640         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18641         e_conv = DecodeError_clone(&e_conv);
18642         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18643         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
18644         return (int64_t)ret_conv;
18645 }
18646
18647 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18648         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
18649         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
18650         return ret_conv;
18651 }
18652
18653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18654         if ((_res & 1) != 0) return;
18655         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18656         CHECK_ACCESS(_res_ptr);
18657         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
18658         FREE((void*)_res);
18659         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
18660 }
18661
18662 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
18663         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18664         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
18665         return (int64_t)ret_conv;
18666 }
18667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18668         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
18669         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
18670         return ret_conv;
18671 }
18672
18673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18674         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
18675         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18676         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
18677         return (int64_t)ret_conv;
18678 }
18679
18680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
18681         LDKCVec_PaymentPreimageZ _res_constr;
18682         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18683         if (_res_constr.datalen > 0)
18684                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
18685         else
18686                 _res_constr.data = NULL;
18687         for (size_t i = 0; i < _res_constr.datalen; i++) {
18688                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
18689                 LDKThirtyTwoBytes _res_conv_8_ref;
18690                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
18691                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
18692                 _res_constr.data[i] = _res_conv_8_ref;
18693         }
18694         CVec_PaymentPreimageZ_free(_res_constr);
18695 }
18696
18697 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
18698         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
18699         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
18700         return ((int64_t)ret_conv);
18701 }
18702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18703         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
18704         int64_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
18705         return ret_conv;
18706 }
18707
18708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18709         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
18710         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
18711         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
18712         return ((int64_t)ret_conv);
18713 }
18714
18715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
18716         LDKSignature a_ref;
18717         CHECK((*env)->GetArrayLength(env, a) == 64);
18718         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
18719         LDKCVec_SignatureZ b_constr;
18720         b_constr.datalen = (*env)->GetArrayLength(env, b);
18721         if (b_constr.datalen > 0)
18722                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18723         else
18724                 b_constr.data = NULL;
18725         for (size_t i = 0; i < b_constr.datalen; i++) {
18726                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
18727                 LDKSignature b_conv_8_ref;
18728                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
18729                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
18730                 b_constr.data[i] = b_conv_8_ref;
18731         }
18732         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
18733         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
18734         return ((int64_t)ret_conv);
18735 }
18736
18737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18738         if ((_res & 1) != 0) return;
18739         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18740         CHECK_ACCESS(_res_ptr);
18741         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
18742         FREE((void*)_res);
18743         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
18744 }
18745
18746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18747         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18748         CHECK_ACCESS(o_ptr);
18749         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
18750         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
18751         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18752         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
18753         return (int64_t)ret_conv;
18754 }
18755
18756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
18757         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18758         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
18759         return (int64_t)ret_conv;
18760 }
18761
18762 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18763         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
18764         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
18765         return ret_conv;
18766 }
18767
18768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18769         if ((_res & 1) != 0) return;
18770         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18771         CHECK_ACCESS(_res_ptr);
18772         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
18773         FREE((void*)_res);
18774         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
18775 }
18776
18777 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
18778         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18779         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
18780         return (int64_t)ret_conv;
18781 }
18782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18783         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
18784         int64_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
18785         return ret_conv;
18786 }
18787
18788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18789         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
18790         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18791         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
18792         return (int64_t)ret_conv;
18793 }
18794
18795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18796         LDKSignature o_ref;
18797         CHECK((*env)->GetArrayLength(env, o) == 64);
18798         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
18799         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18800         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
18801         return (int64_t)ret_conv;
18802 }
18803
18804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
18805         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18806         *ret_conv = CResult_SignatureNoneZ_err();
18807         return (int64_t)ret_conv;
18808 }
18809
18810 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18811         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
18812         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
18813         return ret_conv;
18814 }
18815
18816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18817         if ((_res & 1) != 0) return;
18818         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18819         CHECK_ACCESS(_res_ptr);
18820         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
18821         FREE((void*)_res);
18822         CResult_SignatureNoneZ_free(_res_conv);
18823 }
18824
18825 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
18826         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18827         *ret_conv = CResult_SignatureNoneZ_clone(arg);
18828         return (int64_t)ret_conv;
18829 }
18830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18831         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
18832         int64_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
18833         return ret_conv;
18834 }
18835
18836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18837         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
18838         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18839         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
18840         return (int64_t)ret_conv;
18841 }
18842
18843 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
18844         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
18845         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
18846         return ((int64_t)ret_conv);
18847 }
18848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18849         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
18850         int64_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
18851         return ret_conv;
18852 }
18853
18854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18855         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
18856         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
18857         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
18858         return ((int64_t)ret_conv);
18859 }
18860
18861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
18862         LDKSignature a_ref;
18863         CHECK((*env)->GetArrayLength(env, a) == 64);
18864         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
18865         LDKSignature b_ref;
18866         CHECK((*env)->GetArrayLength(env, b) == 64);
18867         (*env)->GetByteArrayRegion(env, b, 0, 64, b_ref.compact_form);
18868         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
18869         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
18870         return ((int64_t)ret_conv);
18871 }
18872
18873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18874         if ((_res & 1) != 0) return;
18875         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18876         CHECK_ACCESS(_res_ptr);
18877         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
18878         FREE((void*)_res);
18879         C2Tuple_SignatureSignatureZ_free(_res_conv);
18880 }
18881
18882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18883         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18884         CHECK_ACCESS(o_ptr);
18885         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
18886         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
18887         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18888         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
18889         return (int64_t)ret_conv;
18890 }
18891
18892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
18893         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18894         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
18895         return (int64_t)ret_conv;
18896 }
18897
18898 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18899         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
18900         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
18901         return ret_conv;
18902 }
18903
18904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18905         if ((_res & 1) != 0) return;
18906         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18907         CHECK_ACCESS(_res_ptr);
18908         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
18909         FREE((void*)_res);
18910         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
18911 }
18912
18913 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
18914         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18915         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
18916         return (int64_t)ret_conv;
18917 }
18918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18919         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
18920         int64_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
18921         return ret_conv;
18922 }
18923
18924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18925         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
18926         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18927         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
18928         return (int64_t)ret_conv;
18929 }
18930
18931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18932         LDKSecretKey o_ref;
18933         CHECK((*env)->GetArrayLength(env, o) == 32);
18934         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
18935         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18936         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
18937         return (int64_t)ret_conv;
18938 }
18939
18940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1err(JNIEnv *env, jclass clz) {
18941         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18942         *ret_conv = CResult_SecretKeyNoneZ_err();
18943         return (int64_t)ret_conv;
18944 }
18945
18946 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18947         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
18948         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
18949         return ret_conv;
18950 }
18951
18952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18953         if ((_res & 1) != 0) return;
18954         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18955         CHECK_ACCESS(_res_ptr);
18956         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
18957         FREE((void*)_res);
18958         CResult_SecretKeyNoneZ_free(_res_conv);
18959 }
18960
18961 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
18962         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18963         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
18964         return (int64_t)ret_conv;
18965 }
18966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18967         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
18968         int64_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
18969         return ret_conv;
18970 }
18971
18972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18973         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
18974         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18975         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
18976         return (int64_t)ret_conv;
18977 }
18978
18979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18980         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18981         CHECK_ACCESS(o_ptr);
18982         LDKSign o_conv = *(LDKSign*)(o_ptr);
18983         if (o_conv.free == LDKSign_JCalls_free) {
18984                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18985                 LDKSign_JCalls_cloned(&o_conv);
18986         }
18987         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
18988         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
18989         return (int64_t)ret_conv;
18990 }
18991
18992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18993         LDKDecodeError e_conv;
18994         e_conv.inner = (void*)(e & (~1));
18995         e_conv.is_owned = (e & 1) || (e == 0);
18996         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18997         e_conv = DecodeError_clone(&e_conv);
18998         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
18999         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
19000         return (int64_t)ret_conv;
19001 }
19002
19003 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19004         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
19005         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
19006         return ret_conv;
19007 }
19008
19009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19010         if ((_res & 1) != 0) return;
19011         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19012         CHECK_ACCESS(_res_ptr);
19013         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
19014         FREE((void*)_res);
19015         CResult_SignDecodeErrorZ_free(_res_conv);
19016 }
19017
19018 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
19019         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19020         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
19021         return (int64_t)ret_conv;
19022 }
19023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19024         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
19025         int64_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
19026         return ret_conv;
19027 }
19028
19029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19030         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
19031         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19032         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
19033         return (int64_t)ret_conv;
19034 }
19035
19036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19037         LDKCVec_u5Z _res_constr;
19038         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19039         if (_res_constr.datalen > 0)
19040                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
19041         else
19042                 _res_constr.data = NULL;
19043         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
19044         for (size_t h = 0; h < _res_constr.datalen; h++) {
19045                 int8_t _res_conv_7 = _res_vals[h];
19046                 
19047                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
19048         }
19049         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
19050         CVec_u5Z_free(_res_constr);
19051 }
19052
19053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19054         LDKRecoverableSignature o_ref;
19055         CHECK((*env)->GetArrayLength(env, o) == 68);
19056         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
19057         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19058         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
19059         return (int64_t)ret_conv;
19060 }
19061
19062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
19063         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19064         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
19065         return (int64_t)ret_conv;
19066 }
19067
19068 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19069         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
19070         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
19071         return ret_conv;
19072 }
19073
19074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19075         if ((_res & 1) != 0) return;
19076         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19077         CHECK_ACCESS(_res_ptr);
19078         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
19079         FREE((void*)_res);
19080         CResult_RecoverableSignatureNoneZ_free(_res_conv);
19081 }
19082
19083 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
19084         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19085         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
19086         return (int64_t)ret_conv;
19087 }
19088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19089         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
19090         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
19091         return ret_conv;
19092 }
19093
19094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19095         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
19096         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19097         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
19098         return (int64_t)ret_conv;
19099 }
19100
19101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
19102         LDKCVec_u8Z _res_ref;
19103         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
19104         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
19105         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
19106         CVec_u8Z_free(_res_ref);
19107 }
19108
19109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19110         LDKCVec_CVec_u8ZZ _res_constr;
19111         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19112         if (_res_constr.datalen > 0)
19113                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
19114         else
19115                 _res_constr.data = NULL;
19116         for (size_t i = 0; i < _res_constr.datalen; i++) {
19117                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19118                 LDKCVec_u8Z _res_conv_8_ref;
19119                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
19120                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
19121                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
19122                 _res_constr.data[i] = _res_conv_8_ref;
19123         }
19124         CVec_CVec_u8ZZ_free(_res_constr);
19125 }
19126
19127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
19128         LDKCVec_CVec_u8ZZ o_constr;
19129         o_constr.datalen = (*env)->GetArrayLength(env, o);
19130         if (o_constr.datalen > 0)
19131                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
19132         else
19133                 o_constr.data = NULL;
19134         for (size_t i = 0; i < o_constr.datalen; i++) {
19135                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
19136                 LDKCVec_u8Z o_conv_8_ref;
19137                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
19138                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
19139                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
19140                 o_constr.data[i] = o_conv_8_ref;
19141         }
19142         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19143         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
19144         return (int64_t)ret_conv;
19145 }
19146
19147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
19148         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19149         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
19150         return (int64_t)ret_conv;
19151 }
19152
19153 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19154         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
19155         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
19156         return ret_conv;
19157 }
19158
19159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19160         if ((_res & 1) != 0) return;
19161         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19162         CHECK_ACCESS(_res_ptr);
19163         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
19164         FREE((void*)_res);
19165         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
19166 }
19167
19168 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
19169         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19170         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
19171         return (int64_t)ret_conv;
19172 }
19173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19174         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
19175         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
19176         return ret_conv;
19177 }
19178
19179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19180         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
19181         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19182         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
19183         return (int64_t)ret_conv;
19184 }
19185
19186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19187         LDKInMemorySigner o_conv;
19188         o_conv.inner = (void*)(o & (~1));
19189         o_conv.is_owned = (o & 1) || (o == 0);
19190         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19191         o_conv = InMemorySigner_clone(&o_conv);
19192         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19193         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
19194         return (int64_t)ret_conv;
19195 }
19196
19197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19198         LDKDecodeError e_conv;
19199         e_conv.inner = (void*)(e & (~1));
19200         e_conv.is_owned = (e & 1) || (e == 0);
19201         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19202         e_conv = DecodeError_clone(&e_conv);
19203         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19204         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
19205         return (int64_t)ret_conv;
19206 }
19207
19208 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19209         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
19210         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
19211         return ret_conv;
19212 }
19213
19214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19215         if ((_res & 1) != 0) return;
19216         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19217         CHECK_ACCESS(_res_ptr);
19218         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
19219         FREE((void*)_res);
19220         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
19221 }
19222
19223 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
19224         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19225         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
19226         return (int64_t)ret_conv;
19227 }
19228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19229         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
19230         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
19231         return ret_conv;
19232 }
19233
19234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19235         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
19236         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19237         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
19238         return (int64_t)ret_conv;
19239 }
19240
19241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19242         LDKCVec_TxOutZ _res_constr;
19243         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19244         if (_res_constr.datalen > 0)
19245                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
19246         else
19247                 _res_constr.data = NULL;
19248         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19249         for (size_t h = 0; h < _res_constr.datalen; h++) {
19250                 int64_t _res_conv_7 = _res_vals[h];
19251                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
19252                 CHECK_ACCESS(_res_conv_7_ptr);
19253                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
19254                 FREE((void*)_res_conv_7);
19255                 _res_constr.data[h] = _res_conv_7_conv;
19256         }
19257         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19258         CVec_TxOutZ_free(_res_constr);
19259 }
19260
19261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19262         LDKTransaction o_ref;
19263         o_ref.datalen = (*env)->GetArrayLength(env, o);
19264         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
19265         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
19266         o_ref.data_is_owned = true;
19267         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19268         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
19269         return (int64_t)ret_conv;
19270 }
19271
19272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
19273         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19274         *ret_conv = CResult_TransactionNoneZ_err();
19275         return (int64_t)ret_conv;
19276 }
19277
19278 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19279         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
19280         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
19281         return ret_conv;
19282 }
19283
19284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19285         if ((_res & 1) != 0) return;
19286         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19287         CHECK_ACCESS(_res_ptr);
19288         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
19289         FREE((void*)_res);
19290         CResult_TransactionNoneZ_free(_res_conv);
19291 }
19292
19293 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
19294         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19295         *ret_conv = CResult_TransactionNoneZ_clone(arg);
19296         return (int64_t)ret_conv;
19297 }
19298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19299         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
19300         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
19301         return ret_conv;
19302 }
19303
19304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19305         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
19306         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19307         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
19308         return (int64_t)ret_conv;
19309 }
19310
19311 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
19312         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
19313         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
19314         return ((int64_t)ret_conv);
19315 }
19316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19317         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
19318         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
19319         return ret_conv;
19320 }
19321
19322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19323         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
19324         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
19325         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
19326         return ((int64_t)ret_conv);
19327 }
19328
19329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
19330         LDKThirtyTwoBytes a_ref;
19331         CHECK((*env)->GetArrayLength(env, a) == 32);
19332         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19333         LDKChannelMonitor b_conv;
19334         b_conv.inner = (void*)(b & (~1));
19335         b_conv.is_owned = (b & 1) || (b == 0);
19336         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19337         b_conv = ChannelMonitor_clone(&b_conv);
19338         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
19339         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
19340         return ((int64_t)ret_conv);
19341 }
19342
19343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19344         if ((_res & 1) != 0) return;
19345         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19346         CHECK_ACCESS(_res_ptr);
19347         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
19348         FREE((void*)_res);
19349         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
19350 }
19351
19352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19353         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
19354         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19355         if (_res_constr.datalen > 0)
19356                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
19357         else
19358                 _res_constr.data = NULL;
19359         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19360         for (size_t j = 0; j < _res_constr.datalen; j++) {
19361                 int64_t _res_conv_35 = _res_vals[j];
19362                 void* _res_conv_35_ptr = (void*)(((uintptr_t)_res_conv_35) & ~1);
19363                 CHECK_ACCESS(_res_conv_35_ptr);
19364                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
19365                 FREE((void*)_res_conv_35);
19366                 _res_constr.data[j] = _res_conv_35_conv;
19367         }
19368         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19369         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
19370 }
19371
19372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
19373         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
19374         o_constr.datalen = (*env)->GetArrayLength(env, o);
19375         if (o_constr.datalen > 0)
19376                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
19377         else
19378                 o_constr.data = NULL;
19379         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
19380         for (size_t j = 0; j < o_constr.datalen; j++) {
19381                 int64_t o_conv_35 = o_vals[j];
19382                 void* o_conv_35_ptr = (void*)(((uintptr_t)o_conv_35) & ~1);
19383                 CHECK_ACCESS(o_conv_35_ptr);
19384                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
19385                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o_conv_35) & ~1));
19386                 o_constr.data[j] = o_conv_35_conv;
19387         }
19388         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
19389         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
19390         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
19391         return (int64_t)ret_conv;
19392 }
19393
19394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19395         LDKIOError e_conv = LDKIOError_from_java(env, e);
19396         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
19397         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
19398         return (int64_t)ret_conv;
19399 }
19400
19401 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19402         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(o & ~1);
19403         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
19404         return ret_conv;
19405 }
19406
19407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19408         if ((_res & 1) != 0) return;
19409         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19410         CHECK_ACCESS(_res_ptr);
19411         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
19412         FREE((void*)_res);
19413         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
19414 }
19415
19416 static inline uintptr_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
19417         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
19418         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
19419         return (int64_t)ret_conv;
19420 }
19421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19422         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
19423         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
19424         return ret_conv;
19425 }
19426
19427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19428         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
19429         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
19430         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
19431         return (int64_t)ret_conv;
19432 }
19433
19434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
19435         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19436         *ret_copy = COption_u16Z_some(o);
19437         int64_t ret_ref = (uintptr_t)ret_copy;
19438         return ret_ref;
19439 }
19440
19441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
19442         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19443         *ret_copy = COption_u16Z_none();
19444         int64_t ret_ref = (uintptr_t)ret_copy;
19445         return ret_ref;
19446 }
19447
19448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
19449         if ((_res & 1) != 0) return;
19450         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19451         CHECK_ACCESS(_res_ptr);
19452         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
19453         FREE((void*)_res);
19454         COption_u16Z_free(_res_conv);
19455 }
19456
19457 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
19458         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19459         *ret_copy = COption_u16Z_clone(arg);
19460 int64_t ret_ref = (uintptr_t)ret_copy;
19461         return ret_ref;
19462 }
19463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19464         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
19465         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
19466         return ret_conv;
19467 }
19468
19469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19470         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
19471         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19472         *ret_copy = COption_u16Z_clone(orig_conv);
19473         int64_t ret_ref = (uintptr_t)ret_copy;
19474         return ret_ref;
19475 }
19476
19477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
19478         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19479         *ret_conv = CResult_NoneAPIErrorZ_ok();
19480         return (int64_t)ret_conv;
19481 }
19482
19483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19484         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19485         CHECK_ACCESS(e_ptr);
19486         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19487         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19488         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19489         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
19490         return (int64_t)ret_conv;
19491 }
19492
19493 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19494         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
19495         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
19496         return ret_conv;
19497 }
19498
19499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19500         if ((_res & 1) != 0) return;
19501         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19502         CHECK_ACCESS(_res_ptr);
19503         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
19504         FREE((void*)_res);
19505         CResult_NoneAPIErrorZ_free(_res_conv);
19506 }
19507
19508 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
19509         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19510         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
19511         return (int64_t)ret_conv;
19512 }
19513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19514         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
19515         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
19516         return ret_conv;
19517 }
19518
19519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19520         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
19521         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19522         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
19523         return (int64_t)ret_conv;
19524 }
19525
19526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19527         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
19528         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19529         if (_res_constr.datalen > 0)
19530                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
19531         else
19532                 _res_constr.data = NULL;
19533         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19534         for (size_t w = 0; w < _res_constr.datalen; w++) {
19535                 int64_t _res_conv_22 = _res_vals[w];
19536                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
19537                 CHECK_ACCESS(_res_conv_22_ptr);
19538                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
19539                 FREE((void*)_res_conv_22);
19540                 _res_constr.data[w] = _res_conv_22_conv;
19541         }
19542         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19543         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
19544 }
19545
19546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19547         LDKCVec_APIErrorZ _res_constr;
19548         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19549         if (_res_constr.datalen > 0)
19550                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
19551         else
19552                 _res_constr.data = NULL;
19553         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19554         for (size_t k = 0; k < _res_constr.datalen; k++) {
19555                 int64_t _res_conv_10 = _res_vals[k];
19556                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
19557                 CHECK_ACCESS(_res_conv_10_ptr);
19558                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
19559                 FREE((void*)_res_conv_10);
19560                 _res_constr.data[k] = _res_conv_10_conv;
19561         }
19562         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19563         CVec_APIErrorZ_free(_res_constr);
19564 }
19565
19566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19567         LDKThirtyTwoBytes o_ref;
19568         CHECK((*env)->GetArrayLength(env, o) == 32);
19569         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19570         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19571         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
19572         return (int64_t)ret_conv;
19573 }
19574
19575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19576         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19577         CHECK_ACCESS(e_ptr);
19578         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19579         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19580         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19581         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
19582         return (int64_t)ret_conv;
19583 }
19584
19585 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19586         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
19587         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
19588         return ret_conv;
19589 }
19590
19591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19592         if ((_res & 1) != 0) return;
19593         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19594         CHECK_ACCESS(_res_ptr);
19595         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
19596         FREE((void*)_res);
19597         CResult__u832APIErrorZ_free(_res_conv);
19598 }
19599
19600 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
19601         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19602         *ret_conv = CResult__u832APIErrorZ_clone(arg);
19603         return (int64_t)ret_conv;
19604 }
19605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19606         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
19607         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
19608         return ret_conv;
19609 }
19610
19611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19612         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
19613         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19614         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
19615         return (int64_t)ret_conv;
19616 }
19617
19618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19619         LDKThirtyTwoBytes o_ref;
19620         CHECK((*env)->GetArrayLength(env, o) == 32);
19621         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19622         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19623         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
19624         return (int64_t)ret_conv;
19625 }
19626
19627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19628         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19629         CHECK_ACCESS(e_ptr);
19630         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
19631         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
19632         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19633         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
19634         return (int64_t)ret_conv;
19635 }
19636
19637 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19638         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
19639         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
19640         return ret_conv;
19641 }
19642
19643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19644         if ((_res & 1) != 0) return;
19645         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19646         CHECK_ACCESS(_res_ptr);
19647         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
19648         FREE((void*)_res);
19649         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
19650 }
19651
19652 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
19653         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19654         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
19655         return (int64_t)ret_conv;
19656 }
19657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19658         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
19659         int64_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
19660         return ret_conv;
19661 }
19662
19663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19664         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
19665         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19666         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
19667         return (int64_t)ret_conv;
19668 }
19669
19670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
19671         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19672         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
19673         return (int64_t)ret_conv;
19674 }
19675
19676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19677         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19678         CHECK_ACCESS(e_ptr);
19679         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
19680         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
19681         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19682         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
19683         return (int64_t)ret_conv;
19684 }
19685
19686 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19687         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
19688         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
19689         return ret_conv;
19690 }
19691
19692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19693         if ((_res & 1) != 0) return;
19694         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19695         CHECK_ACCESS(_res_ptr);
19696         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
19697         FREE((void*)_res);
19698         CResult_NonePaymentSendFailureZ_free(_res_conv);
19699 }
19700
19701 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
19702         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19703         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
19704         return (int64_t)ret_conv;
19705 }
19706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19707         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
19708         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
19709         return ret_conv;
19710 }
19711
19712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19713         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
19714         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19715         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
19716         return (int64_t)ret_conv;
19717 }
19718
19719 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
19720         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
19721         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
19722         return ((int64_t)ret_conv);
19723 }
19724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19725         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
19726         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
19727         return ret_conv;
19728 }
19729
19730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19731         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
19732         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
19733         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
19734         return ((int64_t)ret_conv);
19735 }
19736
19737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
19738         LDKThirtyTwoBytes a_ref;
19739         CHECK((*env)->GetArrayLength(env, a) == 32);
19740         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19741         LDKThirtyTwoBytes b_ref;
19742         CHECK((*env)->GetArrayLength(env, b) == 32);
19743         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
19744         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
19745         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
19746         return ((int64_t)ret_conv);
19747 }
19748
19749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19750         if ((_res & 1) != 0) return;
19751         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19752         CHECK_ACCESS(_res_ptr);
19753         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
19754         FREE((void*)_res);
19755         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
19756 }
19757
19758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19759         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19760         CHECK_ACCESS(o_ptr);
19761         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
19762         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
19763         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19764         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
19765         return (int64_t)ret_conv;
19766 }
19767
19768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19769         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19770         CHECK_ACCESS(e_ptr);
19771         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
19772         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
19773         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19774         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
19775         return (int64_t)ret_conv;
19776 }
19777
19778 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19779         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
19780         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
19781         return ret_conv;
19782 }
19783
19784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19785         if ((_res & 1) != 0) return;
19786         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19787         CHECK_ACCESS(_res_ptr);
19788         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
19789         FREE((void*)_res);
19790         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
19791 }
19792
19793 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
19794         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19795         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
19796         return (int64_t)ret_conv;
19797 }
19798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19799         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
19800         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
19801         return ret_conv;
19802 }
19803
19804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19805         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
19806         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19807         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
19808         return (int64_t)ret_conv;
19809 }
19810
19811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ThirtyTwoBytesZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19812         LDKCVec_ThirtyTwoBytesZ _res_constr;
19813         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19814         if (_res_constr.datalen > 0)
19815                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
19816         else
19817                 _res_constr.data = NULL;
19818         for (size_t i = 0; i < _res_constr.datalen; i++) {
19819                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19820                 LDKThirtyTwoBytes _res_conv_8_ref;
19821                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
19822                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
19823                 _res_constr.data[i] = _res_conv_8_ref;
19824         }
19825         CVec_ThirtyTwoBytesZ_free(_res_constr);
19826 }
19827
19828 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
19829         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19830         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
19831         return ((int64_t)ret_conv);
19832 }
19833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19834         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
19835         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
19836         return ret_conv;
19837 }
19838
19839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19840         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
19841         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19842         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
19843         return ((int64_t)ret_conv);
19844 }
19845
19846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
19847         LDKThirtyTwoBytes a_ref;
19848         CHECK((*env)->GetArrayLength(env, a) == 32);
19849         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19850         LDKThirtyTwoBytes b_ref;
19851         CHECK((*env)->GetArrayLength(env, b) == 32);
19852         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
19853         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19854         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
19855         return ((int64_t)ret_conv);
19856 }
19857
19858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19859         if ((_res & 1) != 0) return;
19860         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19861         CHECK_ACCESS(_res_ptr);
19862         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
19863         FREE((void*)_res);
19864         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
19865 }
19866
19867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19868         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19869         CHECK_ACCESS(o_ptr);
19870         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
19871         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
19872         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19873         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
19874         return (int64_t)ret_conv;
19875 }
19876
19877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
19878         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19879         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
19880         return (int64_t)ret_conv;
19881 }
19882
19883 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19884         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
19885         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
19886         return ret_conv;
19887 }
19888
19889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19890         if ((_res & 1) != 0) return;
19891         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19892         CHECK_ACCESS(_res_ptr);
19893         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
19894         FREE((void*)_res);
19895         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
19896 }
19897
19898 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
19899         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19900         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
19901         return (int64_t)ret_conv;
19902 }
19903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19904         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
19905         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
19906         return ret_conv;
19907 }
19908
19909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19910         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
19911         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19912         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
19913         return (int64_t)ret_conv;
19914 }
19915
19916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19917         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19918         CHECK_ACCESS(o_ptr);
19919         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
19920         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
19921         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19922         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
19923         return (int64_t)ret_conv;
19924 }
19925
19926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19927         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19928         CHECK_ACCESS(e_ptr);
19929         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19930         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19931         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19932         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
19933         return (int64_t)ret_conv;
19934 }
19935
19936 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19937         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
19938         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
19939         return ret_conv;
19940 }
19941
19942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19943         if ((_res & 1) != 0) return;
19944         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19945         CHECK_ACCESS(_res_ptr);
19946         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
19947         FREE((void*)_res);
19948         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
19949 }
19950
19951 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
19952         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19953         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
19954         return (int64_t)ret_conv;
19955 }
19956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19957         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
19958         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
19959         return ret_conv;
19960 }
19961
19962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19963         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
19964         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19965         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
19966         return (int64_t)ret_conv;
19967 }
19968
19969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19970         LDKThirtyTwoBytes o_ref;
19971         CHECK((*env)->GetArrayLength(env, o) == 32);
19972         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19973         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
19974         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
19975         return (int64_t)ret_conv;
19976 }
19977
19978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
19979         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
19980         *ret_conv = CResult_PaymentSecretNoneZ_err();
19981         return (int64_t)ret_conv;
19982 }
19983
19984 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19985         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
19986         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
19987         return ret_conv;
19988 }
19989
19990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19991         if ((_res & 1) != 0) return;
19992         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19993         CHECK_ACCESS(_res_ptr);
19994         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
19995         FREE((void*)_res);
19996         CResult_PaymentSecretNoneZ_free(_res_conv);
19997 }
19998
19999 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
20000         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
20001         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
20002         return (int64_t)ret_conv;
20003 }
20004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20005         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
20006         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
20007         return ret_conv;
20008 }
20009
20010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20011         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
20012         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
20013         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
20014         return (int64_t)ret_conv;
20015 }
20016
20017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20018         LDKThirtyTwoBytes o_ref;
20019         CHECK((*env)->GetArrayLength(env, o) == 32);
20020         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20021         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20022         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
20023         return (int64_t)ret_conv;
20024 }
20025
20026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20027         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20028         CHECK_ACCESS(e_ptr);
20029         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20030         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
20031         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20032         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
20033         return (int64_t)ret_conv;
20034 }
20035
20036 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20037         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
20038         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
20039         return ret_conv;
20040 }
20041
20042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20043         if ((_res & 1) != 0) return;
20044         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20045         CHECK_ACCESS(_res_ptr);
20046         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
20047         FREE((void*)_res);
20048         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
20049 }
20050
20051 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
20052         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20053         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
20054         return (int64_t)ret_conv;
20055 }
20056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20057         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
20058         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
20059         return ret_conv;
20060 }
20061
20062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20063         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
20064         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20065         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
20066         return (int64_t)ret_conv;
20067 }
20068
20069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20070         LDKThirtyTwoBytes o_ref;
20071         CHECK((*env)->GetArrayLength(env, o) == 32);
20072         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20073         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20074         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
20075         return (int64_t)ret_conv;
20076 }
20077
20078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20079         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20080         CHECK_ACCESS(e_ptr);
20081         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20082         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
20083         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20084         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
20085         return (int64_t)ret_conv;
20086 }
20087
20088 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20089         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
20090         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
20091         return ret_conv;
20092 }
20093
20094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20095         if ((_res & 1) != 0) return;
20096         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20097         CHECK_ACCESS(_res_ptr);
20098         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
20099         FREE((void*)_res);
20100         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
20101 }
20102
20103 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
20104         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20105         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
20106         return (int64_t)ret_conv;
20107 }
20108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20109         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
20110         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
20111         return ret_conv;
20112 }
20113
20114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20115         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
20116         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20117         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
20118         return (int64_t)ret_conv;
20119 }
20120
20121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20122         LDKCounterpartyForwardingInfo o_conv;
20123         o_conv.inner = (void*)(o & (~1));
20124         o_conv.is_owned = (o & 1) || (o == 0);
20125         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20126         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
20127         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20128         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
20129         return (int64_t)ret_conv;
20130 }
20131
20132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20133         LDKDecodeError e_conv;
20134         e_conv.inner = (void*)(e & (~1));
20135         e_conv.is_owned = (e & 1) || (e == 0);
20136         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20137         e_conv = DecodeError_clone(&e_conv);
20138         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20139         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
20140         return (int64_t)ret_conv;
20141 }
20142
20143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20144         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
20145         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
20146         return ret_conv;
20147 }
20148
20149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20150         if ((_res & 1) != 0) return;
20151         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20152         CHECK_ACCESS(_res_ptr);
20153         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
20154         FREE((void*)_res);
20155         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
20156 }
20157
20158 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
20159         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20160         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
20161         return (int64_t)ret_conv;
20162 }
20163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20164         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
20165         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
20166         return ret_conv;
20167 }
20168
20169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20170         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
20171         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20172         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
20173         return (int64_t)ret_conv;
20174 }
20175
20176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20177         LDKChannelCounterparty o_conv;
20178         o_conv.inner = (void*)(o & (~1));
20179         o_conv.is_owned = (o & 1) || (o == 0);
20180         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20181         o_conv = ChannelCounterparty_clone(&o_conv);
20182         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20183         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
20184         return (int64_t)ret_conv;
20185 }
20186
20187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20188         LDKDecodeError e_conv;
20189         e_conv.inner = (void*)(e & (~1));
20190         e_conv.is_owned = (e & 1) || (e == 0);
20191         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20192         e_conv = DecodeError_clone(&e_conv);
20193         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20194         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
20195         return (int64_t)ret_conv;
20196 }
20197
20198 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20199         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
20200         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
20201         return ret_conv;
20202 }
20203
20204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_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_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
20209         FREE((void*)_res);
20210         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
20211 }
20212
20213 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
20214         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20215         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
20216         return (int64_t)ret_conv;
20217 }
20218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20219         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
20220         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
20221         return ret_conv;
20222 }
20223
20224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20225         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
20226         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20227         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
20228         return (int64_t)ret_conv;
20229 }
20230
20231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20232         LDKChannelDetails o_conv;
20233         o_conv.inner = (void*)(o & (~1));
20234         o_conv.is_owned = (o & 1) || (o == 0);
20235         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20236         o_conv = ChannelDetails_clone(&o_conv);
20237         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20238         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
20239         return (int64_t)ret_conv;
20240 }
20241
20242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20243         LDKDecodeError e_conv;
20244         e_conv.inner = (void*)(e & (~1));
20245         e_conv.is_owned = (e & 1) || (e == 0);
20246         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20247         e_conv = DecodeError_clone(&e_conv);
20248         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20249         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
20250         return (int64_t)ret_conv;
20251 }
20252
20253 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20254         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
20255         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
20256         return ret_conv;
20257 }
20258
20259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20260         if ((_res & 1) != 0) return;
20261         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20262         CHECK_ACCESS(_res_ptr);
20263         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
20264         FREE((void*)_res);
20265         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
20266 }
20267
20268 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
20269         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20270         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
20271         return (int64_t)ret_conv;
20272 }
20273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20274         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
20275         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
20276         return ret_conv;
20277 }
20278
20279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20280         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
20281         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20282         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
20283         return (int64_t)ret_conv;
20284 }
20285
20286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20287         LDKPhantomRouteHints o_conv;
20288         o_conv.inner = (void*)(o & (~1));
20289         o_conv.is_owned = (o & 1) || (o == 0);
20290         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20291         o_conv = PhantomRouteHints_clone(&o_conv);
20292         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20293         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
20294         return (int64_t)ret_conv;
20295 }
20296
20297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20298         LDKDecodeError e_conv;
20299         e_conv.inner = (void*)(e & (~1));
20300         e_conv.is_owned = (e & 1) || (e == 0);
20301         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20302         e_conv = DecodeError_clone(&e_conv);
20303         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20304         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
20305         return (int64_t)ret_conv;
20306 }
20307
20308 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20309         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
20310         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
20311         return ret_conv;
20312 }
20313
20314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20315         if ((_res & 1) != 0) return;
20316         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20317         CHECK_ACCESS(_res_ptr);
20318         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
20319         FREE((void*)_res);
20320         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
20321 }
20322
20323 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
20324         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20325         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
20326         return (int64_t)ret_conv;
20327 }
20328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20329         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
20330         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
20331         return ret_conv;
20332 }
20333
20334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20335         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
20336         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20337         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
20338         return (int64_t)ret_conv;
20339 }
20340
20341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20342         LDKCVec_ChannelMonitorZ _res_constr;
20343         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20344         if (_res_constr.datalen > 0)
20345                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
20346         else
20347                 _res_constr.data = NULL;
20348         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20349         for (size_t q = 0; q < _res_constr.datalen; q++) {
20350                 int64_t _res_conv_16 = _res_vals[q];
20351                 LDKChannelMonitor _res_conv_16_conv;
20352                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
20353                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
20354                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
20355                 _res_constr.data[q] = _res_conv_16_conv;
20356         }
20357         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20358         CVec_ChannelMonitorZ_free(_res_constr);
20359 }
20360
20361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
20362         LDKThirtyTwoBytes a_ref;
20363         CHECK((*env)->GetArrayLength(env, a) == 32);
20364         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
20365         LDKChannelManager b_conv;
20366         b_conv.inner = (void*)(b & (~1));
20367         b_conv.is_owned = (b & 1) || (b == 0);
20368         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
20369         // WARNING: we need a move here but no clone is available for LDKChannelManager
20370         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
20371         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
20372         return ((int64_t)ret_conv);
20373 }
20374
20375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20376         if ((_res & 1) != 0) return;
20377         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20378         CHECK_ACCESS(_res_ptr);
20379         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
20380         FREE((void*)_res);
20381         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
20382 }
20383
20384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20385         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20386         CHECK_ACCESS(o_ptr);
20387         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
20388         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
20389         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
20390         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
20391         return (int64_t)ret_conv;
20392 }
20393
20394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20395         LDKDecodeError e_conv;
20396         e_conv.inner = (void*)(e & (~1));
20397         e_conv.is_owned = (e & 1) || (e == 0);
20398         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20399         e_conv = DecodeError_clone(&e_conv);
20400         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
20401         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
20402         return (int64_t)ret_conv;
20403 }
20404
20405 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20406         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
20407         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
20408         return ret_conv;
20409 }
20410
20411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20412         if ((_res & 1) != 0) return;
20413         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20414         CHECK_ACCESS(_res_ptr);
20415         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
20416         FREE((void*)_res);
20417         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
20418 }
20419
20420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20421         LDKChannelConfig o_conv;
20422         o_conv.inner = (void*)(o & (~1));
20423         o_conv.is_owned = (o & 1) || (o == 0);
20424         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20425         o_conv = ChannelConfig_clone(&o_conv);
20426         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20427         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
20428         return (int64_t)ret_conv;
20429 }
20430
20431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20432         LDKDecodeError e_conv;
20433         e_conv.inner = (void*)(e & (~1));
20434         e_conv.is_owned = (e & 1) || (e == 0);
20435         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20436         e_conv = DecodeError_clone(&e_conv);
20437         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20438         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
20439         return (int64_t)ret_conv;
20440 }
20441
20442 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20443         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
20444         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
20445         return ret_conv;
20446 }
20447
20448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20449         if ((_res & 1) != 0) return;
20450         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20451         CHECK_ACCESS(_res_ptr);
20452         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
20453         FREE((void*)_res);
20454         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
20455 }
20456
20457 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
20458         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20459         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
20460         return (int64_t)ret_conv;
20461 }
20462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20463         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
20464         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
20465         return ret_conv;
20466 }
20467
20468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20469         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
20470         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20471         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
20472         return (int64_t)ret_conv;
20473 }
20474
20475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20476         LDKOutPoint o_conv;
20477         o_conv.inner = (void*)(o & (~1));
20478         o_conv.is_owned = (o & 1) || (o == 0);
20479         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20480         o_conv = OutPoint_clone(&o_conv);
20481         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20482         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
20483         return (int64_t)ret_conv;
20484 }
20485
20486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20487         LDKDecodeError e_conv;
20488         e_conv.inner = (void*)(e & (~1));
20489         e_conv.is_owned = (e & 1) || (e == 0);
20490         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20491         e_conv = DecodeError_clone(&e_conv);
20492         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20493         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
20494         return (int64_t)ret_conv;
20495 }
20496
20497 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20498         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
20499         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
20500         return ret_conv;
20501 }
20502
20503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20504         if ((_res & 1) != 0) return;
20505         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20506         CHECK_ACCESS(_res_ptr);
20507         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
20508         FREE((void*)_res);
20509         CResult_OutPointDecodeErrorZ_free(_res_conv);
20510 }
20511
20512 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
20513         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20514         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
20515         return (int64_t)ret_conv;
20516 }
20517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20518         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
20519         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
20520         return ret_conv;
20521 }
20522
20523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20524         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
20525         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20526         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
20527         return (int64_t)ret_conv;
20528 }
20529
20530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20531         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20532         CHECK_ACCESS(o_ptr);
20533         LDKType o_conv = *(LDKType*)(o_ptr);
20534         if (o_conv.free == LDKType_JCalls_free) {
20535                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20536                 LDKType_JCalls_cloned(&o_conv);
20537         }
20538         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20539         *ret_copy = COption_TypeZ_some(o_conv);
20540         int64_t ret_ref = (uintptr_t)ret_copy;
20541         return ret_ref;
20542 }
20543
20544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
20545         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20546         *ret_copy = COption_TypeZ_none();
20547         int64_t ret_ref = (uintptr_t)ret_copy;
20548         return ret_ref;
20549 }
20550
20551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20552         if ((_res & 1) != 0) return;
20553         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20554         CHECK_ACCESS(_res_ptr);
20555         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
20556         FREE((void*)_res);
20557         COption_TypeZ_free(_res_conv);
20558 }
20559
20560 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
20561         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20562         *ret_copy = COption_TypeZ_clone(arg);
20563 int64_t ret_ref = (uintptr_t)ret_copy;
20564         return ret_ref;
20565 }
20566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20567         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
20568         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
20569         return ret_conv;
20570 }
20571
20572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20573         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
20574         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20575         *ret_copy = COption_TypeZ_clone(orig_conv);
20576         int64_t ret_ref = (uintptr_t)ret_copy;
20577         return ret_ref;
20578 }
20579
20580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20581         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20582         CHECK_ACCESS(o_ptr);
20583         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
20584         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
20585         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20586         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
20587         return (int64_t)ret_conv;
20588 }
20589
20590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20591         LDKDecodeError e_conv;
20592         e_conv.inner = (void*)(e & (~1));
20593         e_conv.is_owned = (e & 1) || (e == 0);
20594         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20595         e_conv = DecodeError_clone(&e_conv);
20596         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20597         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
20598         return (int64_t)ret_conv;
20599 }
20600
20601 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20602         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
20603         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
20604         return ret_conv;
20605 }
20606
20607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20608         if ((_res & 1) != 0) return;
20609         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20610         CHECK_ACCESS(_res_ptr);
20611         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
20612         FREE((void*)_res);
20613         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
20614 }
20615
20616 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
20617         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20618         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
20619         return (int64_t)ret_conv;
20620 }
20621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20622         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
20623         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
20624         return ret_conv;
20625 }
20626
20627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20628         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
20629         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20630         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
20631         return (int64_t)ret_conv;
20632 }
20633
20634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20635         LDKThirtyTwoBytes o_ref;
20636         CHECK((*env)->GetArrayLength(env, o) == 32);
20637         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20638         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20639         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
20640         return (int64_t)ret_conv;
20641 }
20642
20643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20644         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20645         CHECK_ACCESS(e_ptr);
20646         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
20647         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
20648         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20649         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
20650         return (int64_t)ret_conv;
20651 }
20652
20653 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20654         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
20655         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
20656         return ret_conv;
20657 }
20658
20659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20660         if ((_res & 1) != 0) return;
20661         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20662         CHECK_ACCESS(_res_ptr);
20663         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
20664         FREE((void*)_res);
20665         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
20666 }
20667
20668 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
20669         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20670         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
20671         return (int64_t)ret_conv;
20672 }
20673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20674         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
20675         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
20676         return ret_conv;
20677 }
20678
20679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20680         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
20681         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20682         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
20683         return (int64_t)ret_conv;
20684 }
20685
20686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
20687         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
20688         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20689         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
20690         return (int64_t)ret_conv;
20691 }
20692
20693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20694         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20695         CHECK_ACCESS(e_ptr);
20696         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
20697         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
20698         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20699         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
20700         return (int64_t)ret_conv;
20701 }
20702
20703 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20704         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
20705         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
20706         return ret_conv;
20707 }
20708
20709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20710         if ((_res & 1) != 0) return;
20711         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20712         CHECK_ACCESS(_res_ptr);
20713         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
20714         FREE((void*)_res);
20715         CResult_SiPrefixParseErrorZ_free(_res_conv);
20716 }
20717
20718 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
20719         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20720         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
20721         return (int64_t)ret_conv;
20722 }
20723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20724         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
20725         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
20726         return ret_conv;
20727 }
20728
20729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20730         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
20731         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20732         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
20733         return (int64_t)ret_conv;
20734 }
20735
20736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20737         LDKInvoice o_conv;
20738         o_conv.inner = (void*)(o & (~1));
20739         o_conv.is_owned = (o & 1) || (o == 0);
20740         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20741         o_conv = Invoice_clone(&o_conv);
20742         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20743         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
20744         return (int64_t)ret_conv;
20745 }
20746
20747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20748         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20749         CHECK_ACCESS(e_ptr);
20750         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
20751         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
20752         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20753         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
20754         return (int64_t)ret_conv;
20755 }
20756
20757 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20758         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
20759         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
20760         return ret_conv;
20761 }
20762
20763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20764         if ((_res & 1) != 0) return;
20765         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20766         CHECK_ACCESS(_res_ptr);
20767         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
20768         FREE((void*)_res);
20769         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
20770 }
20771
20772 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
20773         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20774         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
20775         return (int64_t)ret_conv;
20776 }
20777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20778         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
20779         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
20780         return ret_conv;
20781 }
20782
20783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20784         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
20785         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20786         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
20787         return (int64_t)ret_conv;
20788 }
20789
20790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20791         LDKSignedRawInvoice o_conv;
20792         o_conv.inner = (void*)(o & (~1));
20793         o_conv.is_owned = (o & 1) || (o == 0);
20794         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20795         o_conv = SignedRawInvoice_clone(&o_conv);
20796         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20797         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
20798         return (int64_t)ret_conv;
20799 }
20800
20801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20802         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20803         CHECK_ACCESS(e_ptr);
20804         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
20805         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
20806         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20807         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
20808         return (int64_t)ret_conv;
20809 }
20810
20811 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20812         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
20813         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
20814         return ret_conv;
20815 }
20816
20817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20818         if ((_res & 1) != 0) return;
20819         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20820         CHECK_ACCESS(_res_ptr);
20821         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
20822         FREE((void*)_res);
20823         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
20824 }
20825
20826 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
20827         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20828         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
20829         return (int64_t)ret_conv;
20830 }
20831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20832         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
20833         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
20834         return ret_conv;
20835 }
20836
20837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20838         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
20839         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20840         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
20841         return (int64_t)ret_conv;
20842 }
20843
20844 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
20845         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
20846         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
20847         return ((int64_t)ret_conv);
20848 }
20849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20850         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
20851         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
20852         return ret_conv;
20853 }
20854
20855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20856         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
20857         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
20858         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
20859         return ((int64_t)ret_conv);
20860 }
20861
20862 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) {
20863         LDKRawInvoice a_conv;
20864         a_conv.inner = (void*)(a & (~1));
20865         a_conv.is_owned = (a & 1) || (a == 0);
20866         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20867         a_conv = RawInvoice_clone(&a_conv);
20868         LDKThirtyTwoBytes b_ref;
20869         CHECK((*env)->GetArrayLength(env, b) == 32);
20870         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
20871         LDKInvoiceSignature c_conv;
20872         c_conv.inner = (void*)(c & (~1));
20873         c_conv.is_owned = (c & 1) || (c == 0);
20874         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
20875         c_conv = InvoiceSignature_clone(&c_conv);
20876         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
20877         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
20878         return ((int64_t)ret_conv);
20879 }
20880
20881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20882         if ((_res & 1) != 0) return;
20883         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20884         CHECK_ACCESS(_res_ptr);
20885         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
20886         FREE((void*)_res);
20887         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
20888 }
20889
20890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20891         LDKPayeePubKey o_conv;
20892         o_conv.inner = (void*)(o & (~1));
20893         o_conv.is_owned = (o & 1) || (o == 0);
20894         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20895         o_conv = PayeePubKey_clone(&o_conv);
20896         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20897         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
20898         return (int64_t)ret_conv;
20899 }
20900
20901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20902         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
20903         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20904         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
20905         return (int64_t)ret_conv;
20906 }
20907
20908 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20909         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
20910         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
20911         return ret_conv;
20912 }
20913
20914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20915         if ((_res & 1) != 0) return;
20916         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20917         CHECK_ACCESS(_res_ptr);
20918         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
20919         FREE((void*)_res);
20920         CResult_PayeePubKeyErrorZ_free(_res_conv);
20921 }
20922
20923 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
20924         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20925         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
20926         return (int64_t)ret_conv;
20927 }
20928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20929         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
20930         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
20931         return ret_conv;
20932 }
20933
20934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20935         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
20936         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20937         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
20938         return (int64_t)ret_conv;
20939 }
20940
20941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20942         LDKCVec_PrivateRouteZ _res_constr;
20943         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20944         if (_res_constr.datalen > 0)
20945                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
20946         else
20947                 _res_constr.data = NULL;
20948         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20949         for (size_t o = 0; o < _res_constr.datalen; o++) {
20950                 int64_t _res_conv_14 = _res_vals[o];
20951                 LDKPrivateRoute _res_conv_14_conv;
20952                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
20953                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
20954                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
20955                 _res_constr.data[o] = _res_conv_14_conv;
20956         }
20957         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20958         CVec_PrivateRouteZ_free(_res_constr);
20959 }
20960
20961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20962         LDKPositiveTimestamp o_conv;
20963         o_conv.inner = (void*)(o & (~1));
20964         o_conv.is_owned = (o & 1) || (o == 0);
20965         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20966         o_conv = PositiveTimestamp_clone(&o_conv);
20967         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20968         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
20969         return (int64_t)ret_conv;
20970 }
20971
20972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20973         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
20974         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20975         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
20976         return (int64_t)ret_conv;
20977 }
20978
20979 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20980         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
20981         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
20982         return ret_conv;
20983 }
20984
20985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20986         if ((_res & 1) != 0) return;
20987         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20988         CHECK_ACCESS(_res_ptr);
20989         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
20990         FREE((void*)_res);
20991         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
20992 }
20993
20994 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
20995         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20996         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
20997         return (int64_t)ret_conv;
20998 }
20999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21000         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
21001         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
21002         return ret_conv;
21003 }
21004
21005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21006         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
21007         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
21008         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
21009         return (int64_t)ret_conv;
21010 }
21011
21012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
21013         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21014         *ret_conv = CResult_NoneSemanticErrorZ_ok();
21015         return (int64_t)ret_conv;
21016 }
21017
21018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21019         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
21020         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21021         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
21022         return (int64_t)ret_conv;
21023 }
21024
21025 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21026         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
21027         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
21028         return ret_conv;
21029 }
21030
21031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21032         if ((_res & 1) != 0) return;
21033         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21034         CHECK_ACCESS(_res_ptr);
21035         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
21036         FREE((void*)_res);
21037         CResult_NoneSemanticErrorZ_free(_res_conv);
21038 }
21039
21040 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
21041         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21042         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
21043         return (int64_t)ret_conv;
21044 }
21045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21046         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
21047         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
21048         return ret_conv;
21049 }
21050
21051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21052         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
21053         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21054         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
21055         return (int64_t)ret_conv;
21056 }
21057
21058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21059         LDKInvoice o_conv;
21060         o_conv.inner = (void*)(o & (~1));
21061         o_conv.is_owned = (o & 1) || (o == 0);
21062         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21063         o_conv = Invoice_clone(&o_conv);
21064         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21065         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
21066         return (int64_t)ret_conv;
21067 }
21068
21069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21070         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
21071         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21072         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
21073         return (int64_t)ret_conv;
21074 }
21075
21076 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21077         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
21078         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
21079         return ret_conv;
21080 }
21081
21082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21083         if ((_res & 1) != 0) return;
21084         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21085         CHECK_ACCESS(_res_ptr);
21086         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
21087         FREE((void*)_res);
21088         CResult_InvoiceSemanticErrorZ_free(_res_conv);
21089 }
21090
21091 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
21092         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21093         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
21094         return (int64_t)ret_conv;
21095 }
21096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21097         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
21098         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
21099         return ret_conv;
21100 }
21101
21102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21103         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
21104         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21105         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
21106         return (int64_t)ret_conv;
21107 }
21108
21109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21110         LDKDescription o_conv;
21111         o_conv.inner = (void*)(o & (~1));
21112         o_conv.is_owned = (o & 1) || (o == 0);
21113         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21114         o_conv = Description_clone(&o_conv);
21115         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21116         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
21117         return (int64_t)ret_conv;
21118 }
21119
21120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21121         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
21122         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21123         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
21124         return (int64_t)ret_conv;
21125 }
21126
21127 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21128         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
21129         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
21130         return ret_conv;
21131 }
21132
21133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21134         if ((_res & 1) != 0) return;
21135         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21136         CHECK_ACCESS(_res_ptr);
21137         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
21138         FREE((void*)_res);
21139         CResult_DescriptionCreationErrorZ_free(_res_conv);
21140 }
21141
21142 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
21143         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21144         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
21145         return (int64_t)ret_conv;
21146 }
21147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21148         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
21149         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
21150         return ret_conv;
21151 }
21152
21153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21154         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
21155         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21156         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
21157         return (int64_t)ret_conv;
21158 }
21159
21160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21161         LDKPrivateRoute o_conv;
21162         o_conv.inner = (void*)(o & (~1));
21163         o_conv.is_owned = (o & 1) || (o == 0);
21164         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21165         o_conv = PrivateRoute_clone(&o_conv);
21166         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21167         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
21168         return (int64_t)ret_conv;
21169 }
21170
21171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21172         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
21173         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21174         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
21175         return (int64_t)ret_conv;
21176 }
21177
21178 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21179         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
21180         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
21181         return ret_conv;
21182 }
21183
21184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21185         if ((_res & 1) != 0) return;
21186         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21187         CHECK_ACCESS(_res_ptr);
21188         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
21189         FREE((void*)_res);
21190         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
21191 }
21192
21193 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
21194         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21195         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
21196         return (int64_t)ret_conv;
21197 }
21198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21199         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
21200         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
21201         return ret_conv;
21202 }
21203
21204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21205         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
21206         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21207         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
21208         return (int64_t)ret_conv;
21209 }
21210
21211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
21212         LDKStr o_conv = java_to_owned_str(env, o);
21213         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21214         *ret_conv = CResult_StringErrorZ_ok(o_conv);
21215         return (int64_t)ret_conv;
21216 }
21217
21218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21219         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
21220         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21221         *ret_conv = CResult_StringErrorZ_err(e_conv);
21222         return (int64_t)ret_conv;
21223 }
21224
21225 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21226         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
21227         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
21228         return ret_conv;
21229 }
21230
21231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21232         if ((_res & 1) != 0) return;
21233         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21234         CHECK_ACCESS(_res_ptr);
21235         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
21236         FREE((void*)_res);
21237         CResult_StringErrorZ_free(_res_conv);
21238 }
21239
21240 static inline uintptr_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
21241         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21242         *ret_conv = CResult_StringErrorZ_clone(arg);
21243         return (int64_t)ret_conv;
21244 }
21245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21246         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)(arg & ~1);
21247         int64_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
21248         return ret_conv;
21249 }
21250
21251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21252         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)(orig & ~1);
21253         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21254         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
21255         return (int64_t)ret_conv;
21256 }
21257
21258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21259         LDKChannelMonitorUpdate o_conv;
21260         o_conv.inner = (void*)(o & (~1));
21261         o_conv.is_owned = (o & 1) || (o == 0);
21262         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21263         o_conv = ChannelMonitorUpdate_clone(&o_conv);
21264         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21265         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
21266         return (int64_t)ret_conv;
21267 }
21268
21269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21270         LDKDecodeError e_conv;
21271         e_conv.inner = (void*)(e & (~1));
21272         e_conv.is_owned = (e & 1) || (e == 0);
21273         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21274         e_conv = DecodeError_clone(&e_conv);
21275         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21276         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
21277         return (int64_t)ret_conv;
21278 }
21279
21280 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21281         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
21282         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
21283         return ret_conv;
21284 }
21285
21286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21287         if ((_res & 1) != 0) return;
21288         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21289         CHECK_ACCESS(_res_ptr);
21290         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
21291         FREE((void*)_res);
21292         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
21293 }
21294
21295 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
21296         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21297         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
21298         return (int64_t)ret_conv;
21299 }
21300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21301         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
21302         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
21303         return ret_conv;
21304 }
21305
21306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21307         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
21308         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21309         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
21310         return (int64_t)ret_conv;
21311 }
21312
21313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
21314         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21315         CHECK_ACCESS(o_ptr);
21316         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
21317         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
21318         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
21319         *ret_copy = COption_MonitorEventZ_some(o_conv);
21320         int64_t ret_ref = (uintptr_t)ret_copy;
21321         return ret_ref;
21322 }
21323
21324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
21325         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
21326         *ret_copy = COption_MonitorEventZ_none();
21327         int64_t ret_ref = (uintptr_t)ret_copy;
21328         return ret_ref;
21329 }
21330
21331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21332         if ((_res & 1) != 0) return;
21333         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21334         CHECK_ACCESS(_res_ptr);
21335         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
21336         FREE((void*)_res);
21337         COption_MonitorEventZ_free(_res_conv);
21338 }
21339
21340 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
21341         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
21342         *ret_copy = COption_MonitorEventZ_clone(arg);
21343 int64_t ret_ref = (uintptr_t)ret_copy;
21344         return ret_ref;
21345 }
21346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21347         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
21348         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
21349         return ret_conv;
21350 }
21351
21352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21353         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
21354         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
21355         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
21356         int64_t ret_ref = (uintptr_t)ret_copy;
21357         return ret_ref;
21358 }
21359
21360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21361         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21362         CHECK_ACCESS(o_ptr);
21363         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
21364         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
21365         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21366         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
21367         return (int64_t)ret_conv;
21368 }
21369
21370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21371         LDKDecodeError e_conv;
21372         e_conv.inner = (void*)(e & (~1));
21373         e_conv.is_owned = (e & 1) || (e == 0);
21374         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21375         e_conv = DecodeError_clone(&e_conv);
21376         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21377         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
21378         return (int64_t)ret_conv;
21379 }
21380
21381 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21382         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
21383         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
21384         return ret_conv;
21385 }
21386
21387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21388         if ((_res & 1) != 0) return;
21389         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21390         CHECK_ACCESS(_res_ptr);
21391         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
21392         FREE((void*)_res);
21393         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
21394 }
21395
21396 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
21397         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21398         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
21399         return (int64_t)ret_conv;
21400 }
21401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21402         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
21403         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
21404         return ret_conv;
21405 }
21406
21407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21408         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
21409         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21410         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
21411         return (int64_t)ret_conv;
21412 }
21413
21414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21415         LDKHTLCUpdate o_conv;
21416         o_conv.inner = (void*)(o & (~1));
21417         o_conv.is_owned = (o & 1) || (o == 0);
21418         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21419         o_conv = HTLCUpdate_clone(&o_conv);
21420         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21421         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
21422         return (int64_t)ret_conv;
21423 }
21424
21425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21426         LDKDecodeError e_conv;
21427         e_conv.inner = (void*)(e & (~1));
21428         e_conv.is_owned = (e & 1) || (e == 0);
21429         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21430         e_conv = DecodeError_clone(&e_conv);
21431         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21432         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
21433         return (int64_t)ret_conv;
21434 }
21435
21436 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21437         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
21438         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
21439         return ret_conv;
21440 }
21441
21442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21443         if ((_res & 1) != 0) return;
21444         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21445         CHECK_ACCESS(_res_ptr);
21446         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
21447         FREE((void*)_res);
21448         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
21449 }
21450
21451 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
21452         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21453         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
21454         return (int64_t)ret_conv;
21455 }
21456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21457         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
21458         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
21459         return ret_conv;
21460 }
21461
21462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21463         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
21464         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21465         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
21466         return (int64_t)ret_conv;
21467 }
21468
21469 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
21470         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
21471         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
21472         return ((int64_t)ret_conv);
21473 }
21474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21475         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
21476         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
21477         return ret_conv;
21478 }
21479
21480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21481         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
21482         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
21483         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
21484         return ((int64_t)ret_conv);
21485 }
21486
21487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
21488         LDKOutPoint a_conv;
21489         a_conv.inner = (void*)(a & (~1));
21490         a_conv.is_owned = (a & 1) || (a == 0);
21491         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21492         a_conv = OutPoint_clone(&a_conv);
21493         LDKCVec_u8Z b_ref;
21494         b_ref.datalen = (*env)->GetArrayLength(env, b);
21495         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
21496         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
21497         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
21498         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
21499         return ((int64_t)ret_conv);
21500 }
21501
21502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21503         if ((_res & 1) != 0) return;
21504         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21505         CHECK_ACCESS(_res_ptr);
21506         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
21507         FREE((void*)_res);
21508         C2Tuple_OutPointScriptZ_free(_res_conv);
21509 }
21510
21511 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
21512         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
21513         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
21514         return ((int64_t)ret_conv);
21515 }
21516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21517         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
21518         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
21519         return ret_conv;
21520 }
21521
21522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21523         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
21524         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
21525         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
21526         return ((int64_t)ret_conv);
21527 }
21528
21529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
21530         LDKCVec_u8Z b_ref;
21531         b_ref.datalen = (*env)->GetArrayLength(env, b);
21532         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
21533         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
21534         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
21535         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
21536         return ((int64_t)ret_conv);
21537 }
21538
21539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21540         if ((_res & 1) != 0) return;
21541         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21542         CHECK_ACCESS(_res_ptr);
21543         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
21544         FREE((void*)_res);
21545         C2Tuple_u32ScriptZ_free(_res_conv);
21546 }
21547
21548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21549         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
21550         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21551         if (_res_constr.datalen > 0)
21552                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
21553         else
21554                 _res_constr.data = NULL;
21555         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21556         for (size_t v = 0; v < _res_constr.datalen; v++) {
21557                 int64_t _res_conv_21 = _res_vals[v];
21558                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
21559                 CHECK_ACCESS(_res_conv_21_ptr);
21560                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
21561                 FREE((void*)_res_conv_21);
21562                 _res_constr.data[v] = _res_conv_21_conv;
21563         }
21564         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21565         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
21566 }
21567
21568 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
21569         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
21570         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
21571         return ((int64_t)ret_conv);
21572 }
21573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21574         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
21575         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
21576         return ret_conv;
21577 }
21578
21579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21580         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
21581         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
21582         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
21583         return ((int64_t)ret_conv);
21584 }
21585
21586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
21587         LDKThirtyTwoBytes a_ref;
21588         CHECK((*env)->GetArrayLength(env, a) == 32);
21589         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21590         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
21591         b_constr.datalen = (*env)->GetArrayLength(env, b);
21592         if (b_constr.datalen > 0)
21593                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
21594         else
21595                 b_constr.data = NULL;
21596         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
21597         for (size_t v = 0; v < b_constr.datalen; v++) {
21598                 int64_t b_conv_21 = b_vals[v];
21599                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
21600                 CHECK_ACCESS(b_conv_21_ptr);
21601                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
21602                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
21603                 b_constr.data[v] = b_conv_21_conv;
21604         }
21605         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
21606         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
21607         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
21608         return ((int64_t)ret_conv);
21609 }
21610
21611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21612         if ((_res & 1) != 0) return;
21613         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21614         CHECK_ACCESS(_res_ptr);
21615         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
21616         FREE((void*)_res);
21617         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
21618 }
21619
21620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21621         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
21622         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21623         if (_res_constr.datalen > 0)
21624                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
21625         else
21626                 _res_constr.data = NULL;
21627         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21628         for (size_t o = 0; o < _res_constr.datalen; o++) {
21629                 int64_t _res_conv_40 = _res_vals[o];
21630                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
21631                 CHECK_ACCESS(_res_conv_40_ptr);
21632                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
21633                 FREE((void*)_res_conv_40);
21634                 _res_constr.data[o] = _res_conv_40_conv;
21635         }
21636         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21637         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
21638 }
21639
21640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21641         LDKCVec_EventZ _res_constr;
21642         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21643         if (_res_constr.datalen > 0)
21644                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
21645         else
21646                 _res_constr.data = NULL;
21647         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21648         for (size_t h = 0; h < _res_constr.datalen; h++) {
21649                 int64_t _res_conv_7 = _res_vals[h];
21650                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
21651                 CHECK_ACCESS(_res_conv_7_ptr);
21652                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
21653                 FREE((void*)_res_conv_7);
21654                 _res_constr.data[h] = _res_conv_7_conv;
21655         }
21656         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21657         CVec_EventZ_free(_res_constr);
21658 }
21659
21660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
21661         LDKCVec_TransactionZ _res_constr;
21662         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21663         if (_res_constr.datalen > 0)
21664                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
21665         else
21666                 _res_constr.data = NULL;
21667         for (size_t i = 0; i < _res_constr.datalen; i++) {
21668                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
21669                 LDKTransaction _res_conv_8_ref;
21670                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
21671                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
21672                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
21673                 _res_conv_8_ref.data_is_owned = true;
21674                 _res_constr.data[i] = _res_conv_8_ref;
21675         }
21676         CVec_TransactionZ_free(_res_constr);
21677 }
21678
21679 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
21680         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
21681         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
21682         return ((int64_t)ret_conv);
21683 }
21684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21685         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
21686         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
21687         return ret_conv;
21688 }
21689
21690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21691         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
21692         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
21693         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
21694         return ((int64_t)ret_conv);
21695 }
21696
21697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
21698         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
21699         CHECK_ACCESS(b_ptr);
21700         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
21701         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
21702         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
21703         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
21704         return ((int64_t)ret_conv);
21705 }
21706
21707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21708         if ((_res & 1) != 0) return;
21709         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21710         CHECK_ACCESS(_res_ptr);
21711         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
21712         FREE((void*)_res);
21713         C2Tuple_u32TxOutZ_free(_res_conv);
21714 }
21715
21716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21717         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
21718         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21719         if (_res_constr.datalen > 0)
21720                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
21721         else
21722                 _res_constr.data = NULL;
21723         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21724         for (size_t u = 0; u < _res_constr.datalen; u++) {
21725                 int64_t _res_conv_20 = _res_vals[u];
21726                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
21727                 CHECK_ACCESS(_res_conv_20_ptr);
21728                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
21729                 FREE((void*)_res_conv_20);
21730                 _res_constr.data[u] = _res_conv_20_conv;
21731         }
21732         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21733         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
21734 }
21735
21736 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
21737         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
21738         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
21739         return ((int64_t)ret_conv);
21740 }
21741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21742         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
21743         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
21744         return ret_conv;
21745 }
21746
21747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21748         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
21749         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
21750         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
21751         return ((int64_t)ret_conv);
21752 }
21753
21754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
21755         LDKThirtyTwoBytes a_ref;
21756         CHECK((*env)->GetArrayLength(env, a) == 32);
21757         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21758         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
21759         b_constr.datalen = (*env)->GetArrayLength(env, b);
21760         if (b_constr.datalen > 0)
21761                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
21762         else
21763                 b_constr.data = NULL;
21764         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
21765         for (size_t u = 0; u < b_constr.datalen; u++) {
21766                 int64_t b_conv_20 = b_vals[u];
21767                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
21768                 CHECK_ACCESS(b_conv_20_ptr);
21769                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
21770                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
21771                 b_constr.data[u] = b_conv_20_conv;
21772         }
21773         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
21774         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
21775         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
21776         return ((int64_t)ret_conv);
21777 }
21778
21779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21780         if ((_res & 1) != 0) return;
21781         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21782         CHECK_ACCESS(_res_ptr);
21783         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
21784         FREE((void*)_res);
21785         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
21786 }
21787
21788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21789         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
21790         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21791         if (_res_constr.datalen > 0)
21792                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
21793         else
21794                 _res_constr.data = NULL;
21795         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21796         for (size_t n = 0; n < _res_constr.datalen; n++) {
21797                 int64_t _res_conv_39 = _res_vals[n];
21798                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
21799                 CHECK_ACCESS(_res_conv_39_ptr);
21800                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
21801                 FREE((void*)_res_conv_39);
21802                 _res_constr.data[n] = _res_conv_39_conv;
21803         }
21804         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21805         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
21806 }
21807
21808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21809         LDKCVec_BalanceZ _res_constr;
21810         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21811         if (_res_constr.datalen > 0)
21812                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
21813         else
21814                 _res_constr.data = NULL;
21815         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21816         for (size_t j = 0; j < _res_constr.datalen; j++) {
21817                 int64_t _res_conv_9 = _res_vals[j];
21818                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
21819                 CHECK_ACCESS(_res_conv_9_ptr);
21820                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
21821                 FREE((void*)_res_conv_9);
21822                 _res_constr.data[j] = _res_conv_9_conv;
21823         }
21824         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21825         CVec_BalanceZ_free(_res_constr);
21826 }
21827
21828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21829         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21830         CHECK_ACCESS(o_ptr);
21831         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
21832         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
21833         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21834         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
21835         return (int64_t)ret_conv;
21836 }
21837
21838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21839         LDKDecodeError e_conv;
21840         e_conv.inner = (void*)(e & (~1));
21841         e_conv.is_owned = (e & 1) || (e == 0);
21842         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21843         e_conv = DecodeError_clone(&e_conv);
21844         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21845         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
21846         return (int64_t)ret_conv;
21847 }
21848
21849 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21850         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
21851         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
21852         return ret_conv;
21853 }
21854
21855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21856         if ((_res & 1) != 0) return;
21857         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21858         CHECK_ACCESS(_res_ptr);
21859         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
21860         FREE((void*)_res);
21861         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
21862 }
21863
21864 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
21865         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21866         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
21867         return (int64_t)ret_conv;
21868 }
21869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21870         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
21871         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
21872         return ret_conv;
21873 }
21874
21875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21876         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
21877         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21878         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
21879         return (int64_t)ret_conv;
21880 }
21881
21882 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
21883         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
21884         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
21885         return ((int64_t)ret_conv);
21886 }
21887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21888         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
21889         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
21890         return ret_conv;
21891 }
21892
21893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21894         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
21895         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
21896         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
21897         return ((int64_t)ret_conv);
21898 }
21899
21900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
21901         LDKPublicKey a_ref;
21902         CHECK((*env)->GetArrayLength(env, a) == 33);
21903         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
21904         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
21905         CHECK_ACCESS(b_ptr);
21906         LDKType b_conv = *(LDKType*)(b_ptr);
21907         if (b_conv.free == LDKType_JCalls_free) {
21908                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21909                 LDKType_JCalls_cloned(&b_conv);
21910         }
21911         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
21912         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
21913         return ((int64_t)ret_conv);
21914 }
21915
21916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21917         if ((_res & 1) != 0) return;
21918         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21919         CHECK_ACCESS(_res_ptr);
21920         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
21921         FREE((void*)_res);
21922         C2Tuple_PublicKeyTypeZ_free(_res_conv);
21923 }
21924
21925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21926         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
21927         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21928         if (_res_constr.datalen > 0)
21929                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
21930         else
21931                 _res_constr.data = NULL;
21932         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21933         for (size_t z = 0; z < _res_constr.datalen; z++) {
21934                 int64_t _res_conv_25 = _res_vals[z];
21935                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
21936                 CHECK_ACCESS(_res_conv_25_ptr);
21937                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
21938                 FREE((void*)_res_conv_25);
21939                 _res_constr.data[z] = _res_conv_25_conv;
21940         }
21941         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21942         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
21943 }
21944
21945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
21946         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21947         CHECK_ACCESS(o_ptr);
21948         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
21949         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
21950         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21951         *ret_copy = COption_NetAddressZ_some(o_conv);
21952         int64_t ret_ref = (uintptr_t)ret_copy;
21953         return ret_ref;
21954 }
21955
21956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
21957         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21958         *ret_copy = COption_NetAddressZ_none();
21959         int64_t ret_ref = (uintptr_t)ret_copy;
21960         return ret_ref;
21961 }
21962
21963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21964         if ((_res & 1) != 0) return;
21965         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21966         CHECK_ACCESS(_res_ptr);
21967         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
21968         FREE((void*)_res);
21969         COption_NetAddressZ_free(_res_conv);
21970 }
21971
21972 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
21973         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21974         *ret_copy = COption_NetAddressZ_clone(arg);
21975 int64_t ret_ref = (uintptr_t)ret_copy;
21976         return ret_ref;
21977 }
21978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21979         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
21980         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
21981         return ret_conv;
21982 }
21983
21984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21985         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
21986         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21987         *ret_copy = COption_NetAddressZ_clone(orig_conv);
21988         int64_t ret_ref = (uintptr_t)ret_copy;
21989         return ret_ref;
21990 }
21991
21992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21993         LDKCVec_u8Z o_ref;
21994         o_ref.datalen = (*env)->GetArrayLength(env, o);
21995         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
21996         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
21997         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21998         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
21999         return (int64_t)ret_conv;
22000 }
22001
22002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22003         LDKPeerHandleError e_conv;
22004         e_conv.inner = (void*)(e & (~1));
22005         e_conv.is_owned = (e & 1) || (e == 0);
22006         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22007         e_conv = PeerHandleError_clone(&e_conv);
22008         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22009         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
22010         return (int64_t)ret_conv;
22011 }
22012
22013 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22014         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
22015         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
22016         return ret_conv;
22017 }
22018
22019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22020         if ((_res & 1) != 0) return;
22021         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22022         CHECK_ACCESS(_res_ptr);
22023         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
22024         FREE((void*)_res);
22025         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
22026 }
22027
22028 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
22029         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22030         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
22031         return (int64_t)ret_conv;
22032 }
22033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22034         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
22035         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
22036         return ret_conv;
22037 }
22038
22039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22040         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
22041         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22042         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
22043         return (int64_t)ret_conv;
22044 }
22045
22046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
22047         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22048         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
22049         return (int64_t)ret_conv;
22050 }
22051
22052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22053         LDKPeerHandleError 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 = PeerHandleError_clone(&e_conv);
22058         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22059         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
22060         return (int64_t)ret_conv;
22061 }
22062
22063 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22064         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
22065         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
22066         return ret_conv;
22067 }
22068
22069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_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_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
22074         FREE((void*)_res);
22075         CResult_NonePeerHandleErrorZ_free(_res_conv);
22076 }
22077
22078 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
22079         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22080         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
22081         return (int64_t)ret_conv;
22082 }
22083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22084         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
22085         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
22086         return ret_conv;
22087 }
22088
22089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22090         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
22091         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22092         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
22093         return (int64_t)ret_conv;
22094 }
22095
22096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
22097         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22098         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
22099         return (int64_t)ret_conv;
22100 }
22101
22102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22103         LDKPeerHandleError e_conv;
22104         e_conv.inner = (void*)(e & (~1));
22105         e_conv.is_owned = (e & 1) || (e == 0);
22106         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22107         e_conv = PeerHandleError_clone(&e_conv);
22108         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22109         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
22110         return (int64_t)ret_conv;
22111 }
22112
22113 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22114         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
22115         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
22116         return ret_conv;
22117 }
22118
22119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22120         if ((_res & 1) != 0) return;
22121         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22122         CHECK_ACCESS(_res_ptr);
22123         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
22124         FREE((void*)_res);
22125         CResult_boolPeerHandleErrorZ_free(_res_conv);
22126 }
22127
22128 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
22129         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22130         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
22131         return (int64_t)ret_conv;
22132 }
22133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22134         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
22135         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
22136         return ret_conv;
22137 }
22138
22139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22140         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
22141         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22142         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
22143         return (int64_t)ret_conv;
22144 }
22145
22146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1ok(JNIEnv *env, jclass clz, int32_t o) {
22147         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
22148         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
22149         return (int64_t)ret_conv;
22150 }
22151
22152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22153         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
22154         CHECK_ACCESS(e_ptr);
22155         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
22156         e_conv = GraphSyncError_clone((LDKGraphSyncError*)(((uintptr_t)e) & ~1));
22157         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
22158         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
22159         return (int64_t)ret_conv;
22160 }
22161
22162 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22163         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)(o & ~1);
22164         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
22165         return ret_conv;
22166 }
22167
22168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22169         if ((_res & 1) != 0) return;
22170         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22171         CHECK_ACCESS(_res_ptr);
22172         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
22173         FREE((void*)_res);
22174         CResult_u32GraphSyncErrorZ_free(_res_conv);
22175 }
22176
22177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22178         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
22179         CHECK_ACCESS(o_ptr);
22180         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
22181         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
22182         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
22183         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
22184         return (int64_t)ret_conv;
22185 }
22186
22187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22188         LDKDecodeError e_conv;
22189         e_conv.inner = (void*)(e & (~1));
22190         e_conv.is_owned = (e & 1) || (e == 0);
22191         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22192         e_conv = DecodeError_clone(&e_conv);
22193         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
22194         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
22195         return (int64_t)ret_conv;
22196 }
22197
22198 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22199         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
22200         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
22201         return ret_conv;
22202 }
22203
22204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22205         if ((_res & 1) != 0) return;
22206         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22207         CHECK_ACCESS(_res_ptr);
22208         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
22209         FREE((void*)_res);
22210         CResult_NetAddressDecodeErrorZ_free(_res_conv);
22211 }
22212
22213 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
22214         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
22215         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
22216         return (int64_t)ret_conv;
22217 }
22218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22219         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
22220         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
22221         return ret_conv;
22222 }
22223
22224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22225         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
22226         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
22227         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
22228         return (int64_t)ret_conv;
22229 }
22230
22231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22232         LDKCVec_UpdateAddHTLCZ _res_constr;
22233         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22234         if (_res_constr.datalen > 0)
22235                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
22236         else
22237                 _res_constr.data = NULL;
22238         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22239         for (size_t p = 0; p < _res_constr.datalen; p++) {
22240                 int64_t _res_conv_15 = _res_vals[p];
22241                 LDKUpdateAddHTLC _res_conv_15_conv;
22242                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
22243                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
22244                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
22245                 _res_constr.data[p] = _res_conv_15_conv;
22246         }
22247         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22248         CVec_UpdateAddHTLCZ_free(_res_constr);
22249 }
22250
22251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22252         LDKCVec_UpdateFulfillHTLCZ _res_constr;
22253         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22254         if (_res_constr.datalen > 0)
22255                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
22256         else
22257                 _res_constr.data = NULL;
22258         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22259         for (size_t t = 0; t < _res_constr.datalen; t++) {
22260                 int64_t _res_conv_19 = _res_vals[t];
22261                 LDKUpdateFulfillHTLC _res_conv_19_conv;
22262                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
22263                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
22264                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
22265                 _res_constr.data[t] = _res_conv_19_conv;
22266         }
22267         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22268         CVec_UpdateFulfillHTLCZ_free(_res_constr);
22269 }
22270
22271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22272         LDKCVec_UpdateFailHTLCZ _res_constr;
22273         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22274         if (_res_constr.datalen > 0)
22275                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
22276         else
22277                 _res_constr.data = NULL;
22278         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22279         for (size_t q = 0; q < _res_constr.datalen; q++) {
22280                 int64_t _res_conv_16 = _res_vals[q];
22281                 LDKUpdateFailHTLC _res_conv_16_conv;
22282                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
22283                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
22284                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
22285                 _res_constr.data[q] = _res_conv_16_conv;
22286         }
22287         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22288         CVec_UpdateFailHTLCZ_free(_res_constr);
22289 }
22290
22291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22292         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
22293         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22294         if (_res_constr.datalen > 0)
22295                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
22296         else
22297                 _res_constr.data = NULL;
22298         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22299         for (size_t z = 0; z < _res_constr.datalen; z++) {
22300                 int64_t _res_conv_25 = _res_vals[z];
22301                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
22302                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
22303                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
22304                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
22305                 _res_constr.data[z] = _res_conv_25_conv;
22306         }
22307         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22308         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
22309 }
22310
22311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22312         LDKAcceptChannel o_conv;
22313         o_conv.inner = (void*)(o & (~1));
22314         o_conv.is_owned = (o & 1) || (o == 0);
22315         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22316         o_conv = AcceptChannel_clone(&o_conv);
22317         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
22318         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
22319         return (int64_t)ret_conv;
22320 }
22321
22322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22323         LDKDecodeError e_conv;
22324         e_conv.inner = (void*)(e & (~1));
22325         e_conv.is_owned = (e & 1) || (e == 0);
22326         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22327         e_conv = DecodeError_clone(&e_conv);
22328         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
22329         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
22330         return (int64_t)ret_conv;
22331 }
22332
22333 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22334         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
22335         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
22336         return ret_conv;
22337 }
22338
22339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22340         if ((_res & 1) != 0) return;
22341         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22342         CHECK_ACCESS(_res_ptr);
22343         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
22344         FREE((void*)_res);
22345         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
22346 }
22347
22348 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
22349         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
22350         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
22351         return (int64_t)ret_conv;
22352 }
22353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22354         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
22355         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
22356         return ret_conv;
22357 }
22358
22359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22360         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
22361         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
22362         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
22363         return (int64_t)ret_conv;
22364 }
22365
22366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22367         LDKAnnouncementSignatures o_conv;
22368         o_conv.inner = (void*)(o & (~1));
22369         o_conv.is_owned = (o & 1) || (o == 0);
22370         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22371         o_conv = AnnouncementSignatures_clone(&o_conv);
22372         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
22373         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
22374         return (int64_t)ret_conv;
22375 }
22376
22377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22378         LDKDecodeError e_conv;
22379         e_conv.inner = (void*)(e & (~1));
22380         e_conv.is_owned = (e & 1) || (e == 0);
22381         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22382         e_conv = DecodeError_clone(&e_conv);
22383         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
22384         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
22385         return (int64_t)ret_conv;
22386 }
22387
22388 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22389         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
22390         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
22391         return ret_conv;
22392 }
22393
22394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22395         if ((_res & 1) != 0) return;
22396         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22397         CHECK_ACCESS(_res_ptr);
22398         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
22399         FREE((void*)_res);
22400         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
22401 }
22402
22403 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
22404         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
22405         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
22406         return (int64_t)ret_conv;
22407 }
22408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22409         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
22410         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
22411         return ret_conv;
22412 }
22413
22414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22415         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
22416         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
22417         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
22418         return (int64_t)ret_conv;
22419 }
22420
22421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22422         LDKChannelReestablish o_conv;
22423         o_conv.inner = (void*)(o & (~1));
22424         o_conv.is_owned = (o & 1) || (o == 0);
22425         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22426         o_conv = ChannelReestablish_clone(&o_conv);
22427         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22428         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
22429         return (int64_t)ret_conv;
22430 }
22431
22432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22433         LDKDecodeError e_conv;
22434         e_conv.inner = (void*)(e & (~1));
22435         e_conv.is_owned = (e & 1) || (e == 0);
22436         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22437         e_conv = DecodeError_clone(&e_conv);
22438         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22439         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
22440         return (int64_t)ret_conv;
22441 }
22442
22443 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22444         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
22445         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
22446         return ret_conv;
22447 }
22448
22449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22450         if ((_res & 1) != 0) return;
22451         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22452         CHECK_ACCESS(_res_ptr);
22453         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
22454         FREE((void*)_res);
22455         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
22456 }
22457
22458 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
22459         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22460         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
22461         return (int64_t)ret_conv;
22462 }
22463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22464         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
22465         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
22466         return ret_conv;
22467 }
22468
22469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22470         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
22471         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22472         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
22473         return (int64_t)ret_conv;
22474 }
22475
22476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22477         LDKClosingSigned o_conv;
22478         o_conv.inner = (void*)(o & (~1));
22479         o_conv.is_owned = (o & 1) || (o == 0);
22480         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22481         o_conv = ClosingSigned_clone(&o_conv);
22482         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22483         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
22484         return (int64_t)ret_conv;
22485 }
22486
22487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22488         LDKDecodeError e_conv;
22489         e_conv.inner = (void*)(e & (~1));
22490         e_conv.is_owned = (e & 1) || (e == 0);
22491         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22492         e_conv = DecodeError_clone(&e_conv);
22493         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22494         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
22495         return (int64_t)ret_conv;
22496 }
22497
22498 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22499         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
22500         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
22501         return ret_conv;
22502 }
22503
22504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22505         if ((_res & 1) != 0) return;
22506         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22507         CHECK_ACCESS(_res_ptr);
22508         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
22509         FREE((void*)_res);
22510         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
22511 }
22512
22513 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
22514         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22515         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
22516         return (int64_t)ret_conv;
22517 }
22518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22519         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
22520         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
22521         return ret_conv;
22522 }
22523
22524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22525         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
22526         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22527         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
22528         return (int64_t)ret_conv;
22529 }
22530
22531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22532         LDKClosingSignedFeeRange o_conv;
22533         o_conv.inner = (void*)(o & (~1));
22534         o_conv.is_owned = (o & 1) || (o == 0);
22535         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22536         o_conv = ClosingSignedFeeRange_clone(&o_conv);
22537         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22538         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
22539         return (int64_t)ret_conv;
22540 }
22541
22542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22543         LDKDecodeError e_conv;
22544         e_conv.inner = (void*)(e & (~1));
22545         e_conv.is_owned = (e & 1) || (e == 0);
22546         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22547         e_conv = DecodeError_clone(&e_conv);
22548         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22549         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
22550         return (int64_t)ret_conv;
22551 }
22552
22553 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22554         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
22555         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
22556         return ret_conv;
22557 }
22558
22559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22560         if ((_res & 1) != 0) return;
22561         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22562         CHECK_ACCESS(_res_ptr);
22563         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
22564         FREE((void*)_res);
22565         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
22566 }
22567
22568 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
22569         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22570         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
22571         return (int64_t)ret_conv;
22572 }
22573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22574         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
22575         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
22576         return ret_conv;
22577 }
22578
22579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22580         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
22581         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22582         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
22583         return (int64_t)ret_conv;
22584 }
22585
22586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22587         LDKCommitmentSigned o_conv;
22588         o_conv.inner = (void*)(o & (~1));
22589         o_conv.is_owned = (o & 1) || (o == 0);
22590         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22591         o_conv = CommitmentSigned_clone(&o_conv);
22592         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22593         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
22594         return (int64_t)ret_conv;
22595 }
22596
22597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22598         LDKDecodeError e_conv;
22599         e_conv.inner = (void*)(e & (~1));
22600         e_conv.is_owned = (e & 1) || (e == 0);
22601         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22602         e_conv = DecodeError_clone(&e_conv);
22603         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22604         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
22605         return (int64_t)ret_conv;
22606 }
22607
22608 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22609         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
22610         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
22611         return ret_conv;
22612 }
22613
22614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22615         if ((_res & 1) != 0) return;
22616         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22617         CHECK_ACCESS(_res_ptr);
22618         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
22619         FREE((void*)_res);
22620         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
22621 }
22622
22623 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
22624         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22625         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
22626         return (int64_t)ret_conv;
22627 }
22628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22629         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
22630         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
22631         return ret_conv;
22632 }
22633
22634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22635         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
22636         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22637         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
22638         return (int64_t)ret_conv;
22639 }
22640
22641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22642         LDKFundingCreated o_conv;
22643         o_conv.inner = (void*)(o & (~1));
22644         o_conv.is_owned = (o & 1) || (o == 0);
22645         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22646         o_conv = FundingCreated_clone(&o_conv);
22647         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22648         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
22649         return (int64_t)ret_conv;
22650 }
22651
22652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22653         LDKDecodeError e_conv;
22654         e_conv.inner = (void*)(e & (~1));
22655         e_conv.is_owned = (e & 1) || (e == 0);
22656         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22657         e_conv = DecodeError_clone(&e_conv);
22658         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22659         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
22660         return (int64_t)ret_conv;
22661 }
22662
22663 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22664         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
22665         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
22666         return ret_conv;
22667 }
22668
22669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22670         if ((_res & 1) != 0) return;
22671         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22672         CHECK_ACCESS(_res_ptr);
22673         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
22674         FREE((void*)_res);
22675         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
22676 }
22677
22678 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
22679         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22680         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
22681         return (int64_t)ret_conv;
22682 }
22683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22684         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
22685         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
22686         return ret_conv;
22687 }
22688
22689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22690         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
22691         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22692         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
22693         return (int64_t)ret_conv;
22694 }
22695
22696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22697         LDKFundingSigned o_conv;
22698         o_conv.inner = (void*)(o & (~1));
22699         o_conv.is_owned = (o & 1) || (o == 0);
22700         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22701         o_conv = FundingSigned_clone(&o_conv);
22702         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22703         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
22704         return (int64_t)ret_conv;
22705 }
22706
22707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22708         LDKDecodeError e_conv;
22709         e_conv.inner = (void*)(e & (~1));
22710         e_conv.is_owned = (e & 1) || (e == 0);
22711         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22712         e_conv = DecodeError_clone(&e_conv);
22713         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22714         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
22715         return (int64_t)ret_conv;
22716 }
22717
22718 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22719         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
22720         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
22721         return ret_conv;
22722 }
22723
22724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22725         if ((_res & 1) != 0) return;
22726         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22727         CHECK_ACCESS(_res_ptr);
22728         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
22729         FREE((void*)_res);
22730         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
22731 }
22732
22733 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
22734         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22735         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
22736         return (int64_t)ret_conv;
22737 }
22738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22739         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
22740         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
22741         return ret_conv;
22742 }
22743
22744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22745         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
22746         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22747         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
22748         return (int64_t)ret_conv;
22749 }
22750
22751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22752         LDKChannelReady o_conv;
22753         o_conv.inner = (void*)(o & (~1));
22754         o_conv.is_owned = (o & 1) || (o == 0);
22755         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22756         o_conv = ChannelReady_clone(&o_conv);
22757         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22758         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
22759         return (int64_t)ret_conv;
22760 }
22761
22762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22763         LDKDecodeError e_conv;
22764         e_conv.inner = (void*)(e & (~1));
22765         e_conv.is_owned = (e & 1) || (e == 0);
22766         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22767         e_conv = DecodeError_clone(&e_conv);
22768         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22769         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
22770         return (int64_t)ret_conv;
22771 }
22772
22773 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22774         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(o & ~1);
22775         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
22776         return ret_conv;
22777 }
22778
22779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22780         if ((_res & 1) != 0) return;
22781         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22782         CHECK_ACCESS(_res_ptr);
22783         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
22784         FREE((void*)_res);
22785         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
22786 }
22787
22788 static inline uintptr_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
22789         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22790         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
22791         return (int64_t)ret_conv;
22792 }
22793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22794         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(arg & ~1);
22795         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
22796         return ret_conv;
22797 }
22798
22799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22800         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(orig & ~1);
22801         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22802         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
22803         return (int64_t)ret_conv;
22804 }
22805
22806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22807         LDKInit o_conv;
22808         o_conv.inner = (void*)(o & (~1));
22809         o_conv.is_owned = (o & 1) || (o == 0);
22810         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22811         o_conv = Init_clone(&o_conv);
22812         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22813         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
22814         return (int64_t)ret_conv;
22815 }
22816
22817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22818         LDKDecodeError e_conv;
22819         e_conv.inner = (void*)(e & (~1));
22820         e_conv.is_owned = (e & 1) || (e == 0);
22821         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22822         e_conv = DecodeError_clone(&e_conv);
22823         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22824         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
22825         return (int64_t)ret_conv;
22826 }
22827
22828 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22829         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
22830         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
22831         return ret_conv;
22832 }
22833
22834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22835         if ((_res & 1) != 0) return;
22836         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22837         CHECK_ACCESS(_res_ptr);
22838         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
22839         FREE((void*)_res);
22840         CResult_InitDecodeErrorZ_free(_res_conv);
22841 }
22842
22843 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
22844         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22845         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
22846         return (int64_t)ret_conv;
22847 }
22848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22849         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
22850         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
22851         return ret_conv;
22852 }
22853
22854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22855         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
22856         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22857         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
22858         return (int64_t)ret_conv;
22859 }
22860
22861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22862         LDKOpenChannel o_conv;
22863         o_conv.inner = (void*)(o & (~1));
22864         o_conv.is_owned = (o & 1) || (o == 0);
22865         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22866         o_conv = OpenChannel_clone(&o_conv);
22867         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22868         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
22869         return (int64_t)ret_conv;
22870 }
22871
22872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22873         LDKDecodeError e_conv;
22874         e_conv.inner = (void*)(e & (~1));
22875         e_conv.is_owned = (e & 1) || (e == 0);
22876         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22877         e_conv = DecodeError_clone(&e_conv);
22878         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22879         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
22880         return (int64_t)ret_conv;
22881 }
22882
22883 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22884         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
22885         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
22886         return ret_conv;
22887 }
22888
22889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22890         if ((_res & 1) != 0) return;
22891         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22892         CHECK_ACCESS(_res_ptr);
22893         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
22894         FREE((void*)_res);
22895         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
22896 }
22897
22898 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
22899         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22900         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
22901         return (int64_t)ret_conv;
22902 }
22903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22904         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
22905         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
22906         return ret_conv;
22907 }
22908
22909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22910         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
22911         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22912         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
22913         return (int64_t)ret_conv;
22914 }
22915
22916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22917         LDKRevokeAndACK o_conv;
22918         o_conv.inner = (void*)(o & (~1));
22919         o_conv.is_owned = (o & 1) || (o == 0);
22920         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22921         o_conv = RevokeAndACK_clone(&o_conv);
22922         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22923         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
22924         return (int64_t)ret_conv;
22925 }
22926
22927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22928         LDKDecodeError e_conv;
22929         e_conv.inner = (void*)(e & (~1));
22930         e_conv.is_owned = (e & 1) || (e == 0);
22931         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22932         e_conv = DecodeError_clone(&e_conv);
22933         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22934         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
22935         return (int64_t)ret_conv;
22936 }
22937
22938 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22939         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
22940         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
22941         return ret_conv;
22942 }
22943
22944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22945         if ((_res & 1) != 0) return;
22946         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22947         CHECK_ACCESS(_res_ptr);
22948         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
22949         FREE((void*)_res);
22950         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
22951 }
22952
22953 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
22954         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22955         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
22956         return (int64_t)ret_conv;
22957 }
22958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22959         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
22960         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
22961         return ret_conv;
22962 }
22963
22964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22965         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
22966         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22967         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
22968         return (int64_t)ret_conv;
22969 }
22970
22971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22972         LDKShutdown o_conv;
22973         o_conv.inner = (void*)(o & (~1));
22974         o_conv.is_owned = (o & 1) || (o == 0);
22975         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22976         o_conv = Shutdown_clone(&o_conv);
22977         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22978         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
22979         return (int64_t)ret_conv;
22980 }
22981
22982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22983         LDKDecodeError e_conv;
22984         e_conv.inner = (void*)(e & (~1));
22985         e_conv.is_owned = (e & 1) || (e == 0);
22986         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22987         e_conv = DecodeError_clone(&e_conv);
22988         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22989         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
22990         return (int64_t)ret_conv;
22991 }
22992
22993 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22994         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
22995         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
22996         return ret_conv;
22997 }
22998
22999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23000         if ((_res & 1) != 0) return;
23001         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23002         CHECK_ACCESS(_res_ptr);
23003         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
23004         FREE((void*)_res);
23005         CResult_ShutdownDecodeErrorZ_free(_res_conv);
23006 }
23007
23008 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
23009         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23010         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
23011         return (int64_t)ret_conv;
23012 }
23013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23014         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
23015         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
23016         return ret_conv;
23017 }
23018
23019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23020         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
23021         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23022         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
23023         return (int64_t)ret_conv;
23024 }
23025
23026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23027         LDKUpdateFailHTLC o_conv;
23028         o_conv.inner = (void*)(o & (~1));
23029         o_conv.is_owned = (o & 1) || (o == 0);
23030         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23031         o_conv = UpdateFailHTLC_clone(&o_conv);
23032         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23033         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
23034         return (int64_t)ret_conv;
23035 }
23036
23037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23038         LDKDecodeError e_conv;
23039         e_conv.inner = (void*)(e & (~1));
23040         e_conv.is_owned = (e & 1) || (e == 0);
23041         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23042         e_conv = DecodeError_clone(&e_conv);
23043         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23044         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
23045         return (int64_t)ret_conv;
23046 }
23047
23048 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23049         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
23050         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
23051         return ret_conv;
23052 }
23053
23054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23055         if ((_res & 1) != 0) return;
23056         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23057         CHECK_ACCESS(_res_ptr);
23058         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
23059         FREE((void*)_res);
23060         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
23061 }
23062
23063 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
23064         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23065         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
23066         return (int64_t)ret_conv;
23067 }
23068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23069         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
23070         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
23071         return ret_conv;
23072 }
23073
23074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23075         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
23076         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23077         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
23078         return (int64_t)ret_conv;
23079 }
23080
23081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23082         LDKUpdateFailMalformedHTLC o_conv;
23083         o_conv.inner = (void*)(o & (~1));
23084         o_conv.is_owned = (o & 1) || (o == 0);
23085         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23086         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
23087         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23088         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
23089         return (int64_t)ret_conv;
23090 }
23091
23092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23093         LDKDecodeError e_conv;
23094         e_conv.inner = (void*)(e & (~1));
23095         e_conv.is_owned = (e & 1) || (e == 0);
23096         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23097         e_conv = DecodeError_clone(&e_conv);
23098         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23099         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
23100         return (int64_t)ret_conv;
23101 }
23102
23103 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23104         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
23105         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
23106         return ret_conv;
23107 }
23108
23109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23110         if ((_res & 1) != 0) return;
23111         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23112         CHECK_ACCESS(_res_ptr);
23113         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
23114         FREE((void*)_res);
23115         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
23116 }
23117
23118 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
23119         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23120         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
23121         return (int64_t)ret_conv;
23122 }
23123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23124         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
23125         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
23126         return ret_conv;
23127 }
23128
23129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23130         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
23131         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23132         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
23133         return (int64_t)ret_conv;
23134 }
23135
23136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23137         LDKUpdateFee o_conv;
23138         o_conv.inner = (void*)(o & (~1));
23139         o_conv.is_owned = (o & 1) || (o == 0);
23140         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23141         o_conv = UpdateFee_clone(&o_conv);
23142         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23143         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
23144         return (int64_t)ret_conv;
23145 }
23146
23147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23148         LDKDecodeError e_conv;
23149         e_conv.inner = (void*)(e & (~1));
23150         e_conv.is_owned = (e & 1) || (e == 0);
23151         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23152         e_conv = DecodeError_clone(&e_conv);
23153         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23154         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
23155         return (int64_t)ret_conv;
23156 }
23157
23158 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23159         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
23160         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
23161         return ret_conv;
23162 }
23163
23164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23165         if ((_res & 1) != 0) return;
23166         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23167         CHECK_ACCESS(_res_ptr);
23168         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
23169         FREE((void*)_res);
23170         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
23171 }
23172
23173 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
23174         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23175         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
23176         return (int64_t)ret_conv;
23177 }
23178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23179         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
23180         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
23181         return ret_conv;
23182 }
23183
23184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23185         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
23186         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23187         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
23188         return (int64_t)ret_conv;
23189 }
23190
23191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23192         LDKUpdateFulfillHTLC o_conv;
23193         o_conv.inner = (void*)(o & (~1));
23194         o_conv.is_owned = (o & 1) || (o == 0);
23195         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23196         o_conv = UpdateFulfillHTLC_clone(&o_conv);
23197         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
23198         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
23199         return (int64_t)ret_conv;
23200 }
23201
23202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23203         LDKDecodeError e_conv;
23204         e_conv.inner = (void*)(e & (~1));
23205         e_conv.is_owned = (e & 1) || (e == 0);
23206         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23207         e_conv = DecodeError_clone(&e_conv);
23208         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
23209         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
23210         return (int64_t)ret_conv;
23211 }
23212
23213 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23214         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
23215         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
23216         return ret_conv;
23217 }
23218
23219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23220         if ((_res & 1) != 0) return;
23221         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23222         CHECK_ACCESS(_res_ptr);
23223         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
23224         FREE((void*)_res);
23225         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
23226 }
23227
23228 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
23229         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
23230         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
23231         return (int64_t)ret_conv;
23232 }
23233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23234         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
23235         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
23236         return ret_conv;
23237 }
23238
23239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23240         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
23241         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
23242         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
23243         return (int64_t)ret_conv;
23244 }
23245
23246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23247         LDKUpdateAddHTLC o_conv;
23248         o_conv.inner = (void*)(o & (~1));
23249         o_conv.is_owned = (o & 1) || (o == 0);
23250         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23251         o_conv = UpdateAddHTLC_clone(&o_conv);
23252         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
23253         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
23254         return (int64_t)ret_conv;
23255 }
23256
23257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23258         LDKDecodeError e_conv;
23259         e_conv.inner = (void*)(e & (~1));
23260         e_conv.is_owned = (e & 1) || (e == 0);
23261         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23262         e_conv = DecodeError_clone(&e_conv);
23263         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
23264         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
23265         return (int64_t)ret_conv;
23266 }
23267
23268 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23269         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
23270         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
23271         return ret_conv;
23272 }
23273
23274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23275         if ((_res & 1) != 0) return;
23276         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23277         CHECK_ACCESS(_res_ptr);
23278         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
23279         FREE((void*)_res);
23280         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
23281 }
23282
23283 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
23284         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
23285         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
23286         return (int64_t)ret_conv;
23287 }
23288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23289         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
23290         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
23291         return ret_conv;
23292 }
23293
23294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23295         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
23296         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
23297         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
23298         return (int64_t)ret_conv;
23299 }
23300
23301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23302         LDKPing o_conv;
23303         o_conv.inner = (void*)(o & (~1));
23304         o_conv.is_owned = (o & 1) || (o == 0);
23305         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23306         o_conv = Ping_clone(&o_conv);
23307         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
23308         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
23309         return (int64_t)ret_conv;
23310 }
23311
23312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23313         LDKDecodeError e_conv;
23314         e_conv.inner = (void*)(e & (~1));
23315         e_conv.is_owned = (e & 1) || (e == 0);
23316         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23317         e_conv = DecodeError_clone(&e_conv);
23318         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
23319         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
23320         return (int64_t)ret_conv;
23321 }
23322
23323 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23324         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
23325         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
23326         return ret_conv;
23327 }
23328
23329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23330         if ((_res & 1) != 0) return;
23331         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23332         CHECK_ACCESS(_res_ptr);
23333         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
23334         FREE((void*)_res);
23335         CResult_PingDecodeErrorZ_free(_res_conv);
23336 }
23337
23338 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
23339         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
23340         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
23341         return (int64_t)ret_conv;
23342 }
23343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23344         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
23345         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
23346         return ret_conv;
23347 }
23348
23349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23350         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
23351         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
23352         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
23353         return (int64_t)ret_conv;
23354 }
23355
23356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23357         LDKPong o_conv;
23358         o_conv.inner = (void*)(o & (~1));
23359         o_conv.is_owned = (o & 1) || (o == 0);
23360         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23361         o_conv = Pong_clone(&o_conv);
23362         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
23363         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
23364         return (int64_t)ret_conv;
23365 }
23366
23367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23368         LDKDecodeError e_conv;
23369         e_conv.inner = (void*)(e & (~1));
23370         e_conv.is_owned = (e & 1) || (e == 0);
23371         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23372         e_conv = DecodeError_clone(&e_conv);
23373         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
23374         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
23375         return (int64_t)ret_conv;
23376 }
23377
23378 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23379         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
23380         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
23381         return ret_conv;
23382 }
23383
23384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23385         if ((_res & 1) != 0) return;
23386         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23387         CHECK_ACCESS(_res_ptr);
23388         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
23389         FREE((void*)_res);
23390         CResult_PongDecodeErrorZ_free(_res_conv);
23391 }
23392
23393 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
23394         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
23395         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
23396         return (int64_t)ret_conv;
23397 }
23398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23399         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
23400         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
23401         return ret_conv;
23402 }
23403
23404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23405         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
23406         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
23407         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
23408         return (int64_t)ret_conv;
23409 }
23410
23411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23412         LDKUnsignedChannelAnnouncement o_conv;
23413         o_conv.inner = (void*)(o & (~1));
23414         o_conv.is_owned = (o & 1) || (o == 0);
23415         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23416         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
23417         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23418         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
23419         return (int64_t)ret_conv;
23420 }
23421
23422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23423         LDKDecodeError e_conv;
23424         e_conv.inner = (void*)(e & (~1));
23425         e_conv.is_owned = (e & 1) || (e == 0);
23426         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23427         e_conv = DecodeError_clone(&e_conv);
23428         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23429         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
23430         return (int64_t)ret_conv;
23431 }
23432
23433 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23434         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
23435         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
23436         return ret_conv;
23437 }
23438
23439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23440         if ((_res & 1) != 0) return;
23441         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23442         CHECK_ACCESS(_res_ptr);
23443         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
23444         FREE((void*)_res);
23445         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
23446 }
23447
23448 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23449         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23450         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
23451         return (int64_t)ret_conv;
23452 }
23453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23454         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
23455         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23456         return ret_conv;
23457 }
23458
23459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23460         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
23461         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23462         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
23463         return (int64_t)ret_conv;
23464 }
23465
23466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23467         LDKChannelAnnouncement o_conv;
23468         o_conv.inner = (void*)(o & (~1));
23469         o_conv.is_owned = (o & 1) || (o == 0);
23470         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23471         o_conv = ChannelAnnouncement_clone(&o_conv);
23472         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23473         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
23474         return (int64_t)ret_conv;
23475 }
23476
23477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23478         LDKDecodeError e_conv;
23479         e_conv.inner = (void*)(e & (~1));
23480         e_conv.is_owned = (e & 1) || (e == 0);
23481         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23482         e_conv = DecodeError_clone(&e_conv);
23483         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23484         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
23485         return (int64_t)ret_conv;
23486 }
23487
23488 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23489         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
23490         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
23491         return ret_conv;
23492 }
23493
23494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23495         if ((_res & 1) != 0) return;
23496         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23497         CHECK_ACCESS(_res_ptr);
23498         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
23499         FREE((void*)_res);
23500         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
23501 }
23502
23503 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23504         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23505         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
23506         return (int64_t)ret_conv;
23507 }
23508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23509         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
23510         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23511         return ret_conv;
23512 }
23513
23514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23515         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
23516         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23517         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
23518         return (int64_t)ret_conv;
23519 }
23520
23521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23522         LDKUnsignedChannelUpdate o_conv;
23523         o_conv.inner = (void*)(o & (~1));
23524         o_conv.is_owned = (o & 1) || (o == 0);
23525         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23526         o_conv = UnsignedChannelUpdate_clone(&o_conv);
23527         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23528         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
23529         return (int64_t)ret_conv;
23530 }
23531
23532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23533         LDKDecodeError e_conv;
23534         e_conv.inner = (void*)(e & (~1));
23535         e_conv.is_owned = (e & 1) || (e == 0);
23536         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23537         e_conv = DecodeError_clone(&e_conv);
23538         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23539         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
23540         return (int64_t)ret_conv;
23541 }
23542
23543 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23544         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
23545         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
23546         return ret_conv;
23547 }
23548
23549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23550         if ((_res & 1) != 0) return;
23551         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23552         CHECK_ACCESS(_res_ptr);
23553         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
23554         FREE((void*)_res);
23555         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
23556 }
23557
23558 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
23559         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23560         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
23561         return (int64_t)ret_conv;
23562 }
23563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23564         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
23565         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
23566         return ret_conv;
23567 }
23568
23569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23570         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
23571         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23572         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
23573         return (int64_t)ret_conv;
23574 }
23575
23576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23577         LDKChannelUpdate o_conv;
23578         o_conv.inner = (void*)(o & (~1));
23579         o_conv.is_owned = (o & 1) || (o == 0);
23580         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23581         o_conv = ChannelUpdate_clone(&o_conv);
23582         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23583         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
23584         return (int64_t)ret_conv;
23585 }
23586
23587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23588         LDKDecodeError e_conv;
23589         e_conv.inner = (void*)(e & (~1));
23590         e_conv.is_owned = (e & 1) || (e == 0);
23591         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23592         e_conv = DecodeError_clone(&e_conv);
23593         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23594         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
23595         return (int64_t)ret_conv;
23596 }
23597
23598 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23599         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
23600         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
23601         return ret_conv;
23602 }
23603
23604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23605         if ((_res & 1) != 0) return;
23606         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23607         CHECK_ACCESS(_res_ptr);
23608         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
23609         FREE((void*)_res);
23610         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
23611 }
23612
23613 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
23614         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23615         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
23616         return (int64_t)ret_conv;
23617 }
23618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23619         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
23620         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
23621         return ret_conv;
23622 }
23623
23624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23625         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
23626         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23627         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
23628         return (int64_t)ret_conv;
23629 }
23630
23631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23632         LDKErrorMessage o_conv;
23633         o_conv.inner = (void*)(o & (~1));
23634         o_conv.is_owned = (o & 1) || (o == 0);
23635         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23636         o_conv = ErrorMessage_clone(&o_conv);
23637         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23638         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
23639         return (int64_t)ret_conv;
23640 }
23641
23642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23643         LDKDecodeError e_conv;
23644         e_conv.inner = (void*)(e & (~1));
23645         e_conv.is_owned = (e & 1) || (e == 0);
23646         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23647         e_conv = DecodeError_clone(&e_conv);
23648         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23649         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
23650         return (int64_t)ret_conv;
23651 }
23652
23653 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23654         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
23655         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
23656         return ret_conv;
23657 }
23658
23659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23660         if ((_res & 1) != 0) return;
23661         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23662         CHECK_ACCESS(_res_ptr);
23663         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
23664         FREE((void*)_res);
23665         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
23666 }
23667
23668 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
23669         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23670         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
23671         return (int64_t)ret_conv;
23672 }
23673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23674         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
23675         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
23676         return ret_conv;
23677 }
23678
23679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23680         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
23681         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23682         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
23683         return (int64_t)ret_conv;
23684 }
23685
23686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23687         LDKWarningMessage o_conv;
23688         o_conv.inner = (void*)(o & (~1));
23689         o_conv.is_owned = (o & 1) || (o == 0);
23690         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23691         o_conv = WarningMessage_clone(&o_conv);
23692         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23693         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
23694         return (int64_t)ret_conv;
23695 }
23696
23697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23698         LDKDecodeError e_conv;
23699         e_conv.inner = (void*)(e & (~1));
23700         e_conv.is_owned = (e & 1) || (e == 0);
23701         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23702         e_conv = DecodeError_clone(&e_conv);
23703         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23704         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
23705         return (int64_t)ret_conv;
23706 }
23707
23708 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23709         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
23710         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
23711         return ret_conv;
23712 }
23713
23714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23715         if ((_res & 1) != 0) return;
23716         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23717         CHECK_ACCESS(_res_ptr);
23718         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
23719         FREE((void*)_res);
23720         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
23721 }
23722
23723 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
23724         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23725         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
23726         return (int64_t)ret_conv;
23727 }
23728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23729         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
23730         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
23731         return ret_conv;
23732 }
23733
23734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23735         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
23736         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23737         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
23738         return (int64_t)ret_conv;
23739 }
23740
23741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23742         LDKUnsignedNodeAnnouncement o_conv;
23743         o_conv.inner = (void*)(o & (~1));
23744         o_conv.is_owned = (o & 1) || (o == 0);
23745         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23746         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
23747         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23748         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
23749         return (int64_t)ret_conv;
23750 }
23751
23752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23753         LDKDecodeError e_conv;
23754         e_conv.inner = (void*)(e & (~1));
23755         e_conv.is_owned = (e & 1) || (e == 0);
23756         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23757         e_conv = DecodeError_clone(&e_conv);
23758         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23759         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
23760         return (int64_t)ret_conv;
23761 }
23762
23763 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23764         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
23765         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
23766         return ret_conv;
23767 }
23768
23769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23770         if ((_res & 1) != 0) return;
23771         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23772         CHECK_ACCESS(_res_ptr);
23773         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
23774         FREE((void*)_res);
23775         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
23776 }
23777
23778 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23779         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23780         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
23781         return (int64_t)ret_conv;
23782 }
23783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23784         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
23785         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23786         return ret_conv;
23787 }
23788
23789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23790         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
23791         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23792         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
23793         return (int64_t)ret_conv;
23794 }
23795
23796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23797         LDKNodeAnnouncement o_conv;
23798         o_conv.inner = (void*)(o & (~1));
23799         o_conv.is_owned = (o & 1) || (o == 0);
23800         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23801         o_conv = NodeAnnouncement_clone(&o_conv);
23802         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23803         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
23804         return (int64_t)ret_conv;
23805 }
23806
23807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23808         LDKDecodeError e_conv;
23809         e_conv.inner = (void*)(e & (~1));
23810         e_conv.is_owned = (e & 1) || (e == 0);
23811         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23812         e_conv = DecodeError_clone(&e_conv);
23813         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23814         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
23815         return (int64_t)ret_conv;
23816 }
23817
23818 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23819         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
23820         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
23821         return ret_conv;
23822 }
23823
23824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23825         if ((_res & 1) != 0) return;
23826         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23827         CHECK_ACCESS(_res_ptr);
23828         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
23829         FREE((void*)_res);
23830         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
23831 }
23832
23833 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23834         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23835         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
23836         return (int64_t)ret_conv;
23837 }
23838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23839         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
23840         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23841         return ret_conv;
23842 }
23843
23844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23845         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
23846         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23847         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
23848         return (int64_t)ret_conv;
23849 }
23850
23851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23852         LDKQueryShortChannelIds o_conv;
23853         o_conv.inner = (void*)(o & (~1));
23854         o_conv.is_owned = (o & 1) || (o == 0);
23855         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23856         o_conv = QueryShortChannelIds_clone(&o_conv);
23857         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23858         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
23859         return (int64_t)ret_conv;
23860 }
23861
23862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23863         LDKDecodeError e_conv;
23864         e_conv.inner = (void*)(e & (~1));
23865         e_conv.is_owned = (e & 1) || (e == 0);
23866         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23867         e_conv = DecodeError_clone(&e_conv);
23868         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23869         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
23870         return (int64_t)ret_conv;
23871 }
23872
23873 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23874         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
23875         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
23876         return ret_conv;
23877 }
23878
23879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23880         if ((_res & 1) != 0) return;
23881         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23882         CHECK_ACCESS(_res_ptr);
23883         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
23884         FREE((void*)_res);
23885         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
23886 }
23887
23888 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
23889         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23890         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
23891         return (int64_t)ret_conv;
23892 }
23893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23894         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
23895         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
23896         return ret_conv;
23897 }
23898
23899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23900         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
23901         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23902         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
23903         return (int64_t)ret_conv;
23904 }
23905
23906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23907         LDKReplyShortChannelIdsEnd o_conv;
23908         o_conv.inner = (void*)(o & (~1));
23909         o_conv.is_owned = (o & 1) || (o == 0);
23910         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23911         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
23912         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23913         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
23914         return (int64_t)ret_conv;
23915 }
23916
23917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23918         LDKDecodeError e_conv;
23919         e_conv.inner = (void*)(e & (~1));
23920         e_conv.is_owned = (e & 1) || (e == 0);
23921         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23922         e_conv = DecodeError_clone(&e_conv);
23923         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23924         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
23925         return (int64_t)ret_conv;
23926 }
23927
23928 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23929         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
23930         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
23931         return ret_conv;
23932 }
23933
23934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23935         if ((_res & 1) != 0) return;
23936         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23937         CHECK_ACCESS(_res_ptr);
23938         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
23939         FREE((void*)_res);
23940         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
23941 }
23942
23943 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
23944         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23945         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
23946         return (int64_t)ret_conv;
23947 }
23948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23949         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
23950         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
23951         return ret_conv;
23952 }
23953
23954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23955         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
23956         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23957         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
23958         return (int64_t)ret_conv;
23959 }
23960
23961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23962         LDKQueryChannelRange o_conv;
23963         o_conv.inner = (void*)(o & (~1));
23964         o_conv.is_owned = (o & 1) || (o == 0);
23965         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23966         o_conv = QueryChannelRange_clone(&o_conv);
23967         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23968         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
23969         return (int64_t)ret_conv;
23970 }
23971
23972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23973         LDKDecodeError e_conv;
23974         e_conv.inner = (void*)(e & (~1));
23975         e_conv.is_owned = (e & 1) || (e == 0);
23976         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23977         e_conv = DecodeError_clone(&e_conv);
23978         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23979         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
23980         return (int64_t)ret_conv;
23981 }
23982
23983 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23984         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
23985         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
23986         return ret_conv;
23987 }
23988
23989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23990         if ((_res & 1) != 0) return;
23991         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23992         CHECK_ACCESS(_res_ptr);
23993         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
23994         FREE((void*)_res);
23995         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
23996 }
23997
23998 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
23999         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24000         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
24001         return (int64_t)ret_conv;
24002 }
24003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24004         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
24005         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
24006         return ret_conv;
24007 }
24008
24009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24010         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
24011         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24012         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
24013         return (int64_t)ret_conv;
24014 }
24015
24016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24017         LDKReplyChannelRange o_conv;
24018         o_conv.inner = (void*)(o & (~1));
24019         o_conv.is_owned = (o & 1) || (o == 0);
24020         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24021         o_conv = ReplyChannelRange_clone(&o_conv);
24022         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24023         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
24024         return (int64_t)ret_conv;
24025 }
24026
24027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24028         LDKDecodeError e_conv;
24029         e_conv.inner = (void*)(e & (~1));
24030         e_conv.is_owned = (e & 1) || (e == 0);
24031         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
24032         e_conv = DecodeError_clone(&e_conv);
24033         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24034         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
24035         return (int64_t)ret_conv;
24036 }
24037
24038 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24039         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
24040         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
24041         return ret_conv;
24042 }
24043
24044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24045         if ((_res & 1) != 0) return;
24046         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
24047         CHECK_ACCESS(_res_ptr);
24048         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
24049         FREE((void*)_res);
24050         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
24051 }
24052
24053 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
24054         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24055         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
24056         return (int64_t)ret_conv;
24057 }
24058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24059         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
24060         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
24061         return ret_conv;
24062 }
24063
24064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24065         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
24066         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24067         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
24068         return (int64_t)ret_conv;
24069 }
24070
24071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24072         LDKGossipTimestampFilter o_conv;
24073         o_conv.inner = (void*)(o & (~1));
24074         o_conv.is_owned = (o & 1) || (o == 0);
24075         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24076         o_conv = GossipTimestampFilter_clone(&o_conv);
24077         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24078         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
24079         return (int64_t)ret_conv;
24080 }
24081
24082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24083         LDKDecodeError e_conv;
24084         e_conv.inner = (void*)(e & (~1));
24085         e_conv.is_owned = (e & 1) || (e == 0);
24086         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
24087         e_conv = DecodeError_clone(&e_conv);
24088         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24089         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
24090         return (int64_t)ret_conv;
24091 }
24092
24093 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24094         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
24095         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
24096         return ret_conv;
24097 }
24098
24099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24100         if ((_res & 1) != 0) return;
24101         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
24102         CHECK_ACCESS(_res_ptr);
24103         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
24104         FREE((void*)_res);
24105         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
24106 }
24107
24108 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
24109         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24110         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
24111         return (int64_t)ret_conv;
24112 }
24113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24114         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
24115         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
24116         return ret_conv;
24117 }
24118
24119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24120         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
24121         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24122         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
24123         return (int64_t)ret_conv;
24124 }
24125
24126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24127         LDKCVec_PhantomRouteHintsZ _res_constr;
24128         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24129         if (_res_constr.datalen > 0)
24130                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
24131         else
24132                 _res_constr.data = NULL;
24133         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24134         for (size_t t = 0; t < _res_constr.datalen; t++) {
24135                 int64_t _res_conv_19 = _res_vals[t];
24136                 LDKPhantomRouteHints _res_conv_19_conv;
24137                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
24138                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
24139                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
24140                 _res_constr.data[t] = _res_conv_19_conv;
24141         }
24142         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24143         CVec_PhantomRouteHintsZ_free(_res_constr);
24144 }
24145
24146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24147         LDKInvoice o_conv;
24148         o_conv.inner = (void*)(o & (~1));
24149         o_conv.is_owned = (o & 1) || (o == 0);
24150         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24151         o_conv = Invoice_clone(&o_conv);
24152         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
24153         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
24154         return (int64_t)ret_conv;
24155 }
24156
24157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24158         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
24159         CHECK_ACCESS(e_ptr);
24160         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
24161         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
24162         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
24163         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
24164         return (int64_t)ret_conv;
24165 }
24166
24167 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24168         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
24169         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
24170         return ret_conv;
24171 }
24172
24173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24174         if ((_res & 1) != 0) return;
24175         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
24176         CHECK_ACCESS(_res_ptr);
24177         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
24178         FREE((void*)_res);
24179         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
24180 }
24181
24182 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
24183         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
24184         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
24185         return (int64_t)ret_conv;
24186 }
24187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24188         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
24189         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
24190         return ret_conv;
24191 }
24192
24193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24194         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
24195         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
24196         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
24197         return (int64_t)ret_conv;
24198 }
24199
24200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
24201         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
24202         CHECK_ACCESS(o_ptr);
24203         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
24204         if (o_conv.free == LDKFilter_JCalls_free) {
24205                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24206                 LDKFilter_JCalls_cloned(&o_conv);
24207         }
24208         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
24209         *ret_copy = COption_FilterZ_some(o_conv);
24210         int64_t ret_ref = (uintptr_t)ret_copy;
24211         return ret_ref;
24212 }
24213
24214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
24215         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
24216         *ret_copy = COption_FilterZ_none();
24217         int64_t ret_ref = (uintptr_t)ret_copy;
24218         return ret_ref;
24219 }
24220
24221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24222         if ((_res & 1) != 0) return;
24223         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
24224         CHECK_ACCESS(_res_ptr);
24225         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
24226         FREE((void*)_res);
24227         COption_FilterZ_free(_res_conv);
24228 }
24229
24230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24231         LDKLockedChannelMonitor o_conv;
24232         o_conv.inner = (void*)(o & (~1));
24233         o_conv.is_owned = (o & 1) || (o == 0);
24234         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24235         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
24236         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
24237         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
24238         return (int64_t)ret_conv;
24239 }
24240
24241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
24242         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
24243         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
24244         return (int64_t)ret_conv;
24245 }
24246
24247 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24248         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
24249         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
24250         return ret_conv;
24251 }
24252
24253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24254         if ((_res & 1) != 0) return;
24255         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
24256         CHECK_ACCESS(_res_ptr);
24257         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
24258         FREE((void*)_res);
24259         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
24260 }
24261
24262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24263         LDKCVec_OutPointZ _res_constr;
24264         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24265         if (_res_constr.datalen > 0)
24266                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
24267         else
24268                 _res_constr.data = NULL;
24269         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24270         for (size_t k = 0; k < _res_constr.datalen; k++) {
24271                 int64_t _res_conv_10 = _res_vals[k];
24272                 LDKOutPoint _res_conv_10_conv;
24273                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
24274                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
24275                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
24276                 _res_constr.data[k] = _res_conv_10_conv;
24277         }
24278         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24279         CVec_OutPointZ_free(_res_constr);
24280 }
24281
24282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24283         if ((this_ptr & 1) != 0) return;
24284         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24285         CHECK_ACCESS(this_ptr_ptr);
24286         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
24287         FREE((void*)this_ptr);
24288         PaymentPurpose_free(this_ptr_conv);
24289 }
24290
24291 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
24292         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
24293         *ret_copy = PaymentPurpose_clone(arg);
24294 int64_t ret_ref = (uintptr_t)ret_copy;
24295         return ret_ref;
24296 }
24297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24298         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
24299         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
24300         return ret_conv;
24301 }
24302
24303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24304         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
24305         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
24306         *ret_copy = PaymentPurpose_clone(orig_conv);
24307         int64_t ret_ref = (uintptr_t)ret_copy;
24308         return ret_ref;
24309 }
24310
24311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
24312         LDKThirtyTwoBytes payment_preimage_ref;
24313         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
24314         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
24315         LDKThirtyTwoBytes payment_secret_ref;
24316         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
24317         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
24318         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
24319         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
24320         int64_t ret_ref = (uintptr_t)ret_copy;
24321         return ret_ref;
24322 }
24323
24324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
24325         LDKThirtyTwoBytes a_ref;
24326         CHECK((*env)->GetArrayLength(env, a) == 32);
24327         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
24328         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
24329         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
24330         int64_t ret_ref = (uintptr_t)ret_copy;
24331         return ret_ref;
24332 }
24333
24334 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1write(JNIEnv *env, jclass clz, int64_t obj) {
24335         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)obj;
24336         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
24337         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24338         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24339         CVec_u8Z_free(ret_var);
24340         return ret_arr;
24341 }
24342
24343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24344         LDKu8slice ser_ref;
24345         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24346         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24347         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
24348         *ret_conv = PaymentPurpose_read(ser_ref);
24349         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24350         return (int64_t)ret_conv;
24351 }
24352
24353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24354         if ((this_ptr & 1) != 0) return;
24355         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24356         CHECK_ACCESS(this_ptr_ptr);
24357         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
24358         FREE((void*)this_ptr);
24359         ClosureReason_free(this_ptr_conv);
24360 }
24361
24362 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
24363         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24364         *ret_copy = ClosureReason_clone(arg);
24365 int64_t ret_ref = (uintptr_t)ret_copy;
24366         return ret_ref;
24367 }
24368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24369         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
24370         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
24371         return ret_conv;
24372 }
24373
24374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24375         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
24376         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24377         *ret_copy = ClosureReason_clone(orig_conv);
24378         int64_t ret_ref = (uintptr_t)ret_copy;
24379         return ret_ref;
24380 }
24381
24382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
24383         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
24384         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24385         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
24386         int64_t ret_ref = (uintptr_t)ret_copy;
24387         return ret_ref;
24388 }
24389
24390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
24391         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24392         *ret_copy = ClosureReason_holder_force_closed();
24393         int64_t ret_ref = (uintptr_t)ret_copy;
24394         return ret_ref;
24395 }
24396
24397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
24398         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24399         *ret_copy = ClosureReason_cooperative_closure();
24400         int64_t ret_ref = (uintptr_t)ret_copy;
24401         return ret_ref;
24402 }
24403
24404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
24405         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24406         *ret_copy = ClosureReason_commitment_tx_confirmed();
24407         int64_t ret_ref = (uintptr_t)ret_copy;
24408         return ret_ref;
24409 }
24410
24411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
24412         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24413         *ret_copy = ClosureReason_funding_timed_out();
24414         int64_t ret_ref = (uintptr_t)ret_copy;
24415         return ret_ref;
24416 }
24417
24418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
24419         LDKStr err_conv = java_to_owned_str(env, err);
24420         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24421         *ret_copy = ClosureReason_processing_error(err_conv);
24422         int64_t ret_ref = (uintptr_t)ret_copy;
24423         return ret_ref;
24424 }
24425
24426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
24427         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24428         *ret_copy = ClosureReason_disconnected_peer();
24429         int64_t ret_ref = (uintptr_t)ret_copy;
24430         return ret_ref;
24431 }
24432
24433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
24434         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24435         *ret_copy = ClosureReason_outdated_channel_manager();
24436         int64_t ret_ref = (uintptr_t)ret_copy;
24437         return ret_ref;
24438 }
24439
24440 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
24441         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
24442         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
24443         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24444         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24445         CVec_u8Z_free(ret_var);
24446         return ret_arr;
24447 }
24448
24449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24450         LDKu8slice ser_ref;
24451         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24452         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24453         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
24454         *ret_conv = ClosureReason_read(ser_ref);
24455         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24456         return (int64_t)ret_conv;
24457 }
24458
24459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24460         if ((this_ptr & 1) != 0) return;
24461         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24462         CHECK_ACCESS(this_ptr_ptr);
24463         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
24464         FREE((void*)this_ptr);
24465         HTLCDestination_free(this_ptr_conv);
24466 }
24467
24468 static inline uintptr_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
24469         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
24470         *ret_copy = HTLCDestination_clone(arg);
24471 int64_t ret_ref = (uintptr_t)ret_copy;
24472         return ret_ref;
24473 }
24474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24475         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)arg;
24476         int64_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
24477         return ret_conv;
24478 }
24479
24480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24481         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)orig;
24482         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
24483         *ret_copy = HTLCDestination_clone(orig_conv);
24484         int64_t ret_ref = (uintptr_t)ret_copy;
24485         return ret_ref;
24486 }
24487
24488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1next_1hop_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int8_tArray channel_id) {
24489         LDKPublicKey node_id_ref;
24490         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24491         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24492         LDKThirtyTwoBytes channel_id_ref;
24493         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24494         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
24495         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
24496         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
24497         int64_t ret_ref = (uintptr_t)ret_copy;
24498         return ret_ref;
24499 }
24500
24501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1unknown_1next_1hop(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
24502         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
24503         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
24504         int64_t ret_ref = (uintptr_t)ret_copy;
24505         return ret_ref;
24506 }
24507
24508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1failed_1payment(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
24509         LDKThirtyTwoBytes payment_hash_ref;
24510         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24511         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24512         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
24513         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
24514         int64_t ret_ref = (uintptr_t)ret_copy;
24515         return ret_ref;
24516 }
24517
24518 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1write(JNIEnv *env, jclass clz, int64_t obj) {
24519         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)obj;
24520         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
24521         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24522         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24523         CVec_u8Z_free(ret_var);
24524         return ret_arr;
24525 }
24526
24527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24528         LDKu8slice ser_ref;
24529         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24530         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24531         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
24532         *ret_conv = HTLCDestination_read(ser_ref);
24533         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24534         return (int64_t)ret_conv;
24535 }
24536
24537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24538         if ((this_ptr & 1) != 0) return;
24539         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24540         CHECK_ACCESS(this_ptr_ptr);
24541         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
24542         FREE((void*)this_ptr);
24543         Event_free(this_ptr_conv);
24544 }
24545
24546 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
24547         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24548         *ret_copy = Event_clone(arg);
24549 int64_t ret_ref = (uintptr_t)ret_copy;
24550         return ret_ref;
24551 }
24552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24553         LDKEvent* arg_conv = (LDKEvent*)arg;
24554         int64_t ret_conv = Event_clone_ptr(arg_conv);
24555         return ret_conv;
24556 }
24557
24558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24559         LDKEvent* orig_conv = (LDKEvent*)orig;
24560         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24561         *ret_copy = Event_clone(orig_conv);
24562         int64_t ret_ref = (uintptr_t)ret_copy;
24563         return ret_ref;
24564 }
24565
24566 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) {
24567         LDKThirtyTwoBytes temporary_channel_id_ref;
24568         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
24569         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
24570         LDKPublicKey counterparty_node_id_ref;
24571         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
24572         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
24573         LDKCVec_u8Z output_script_ref;
24574         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
24575         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
24576         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
24577         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24578         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
24579         int64_t ret_ref = (uintptr_t)ret_copy;
24580         return ret_ref;
24581 }
24582
24583 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) {
24584         LDKThirtyTwoBytes payment_hash_ref;
24585         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24586         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24587         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
24588         CHECK_ACCESS(purpose_ptr);
24589         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
24590         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
24591         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24592         *ret_copy = Event_payment_received(payment_hash_ref, amount_msat, purpose_conv);
24593         int64_t ret_ref = (uintptr_t)ret_copy;
24594         return ret_ref;
24595 }
24596
24597 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) {
24598         LDKThirtyTwoBytes payment_hash_ref;
24599         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24600         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24601         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
24602         CHECK_ACCESS(purpose_ptr);
24603         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
24604         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
24605         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24606         *ret_copy = Event_payment_claimed(payment_hash_ref, amount_msat, purpose_conv);
24607         int64_t ret_ref = (uintptr_t)ret_copy;
24608         return ret_ref;
24609 }
24610
24611 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) {
24612         LDKThirtyTwoBytes payment_id_ref;
24613         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24614         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24615         LDKThirtyTwoBytes payment_preimage_ref;
24616         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
24617         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
24618         LDKThirtyTwoBytes payment_hash_ref;
24619         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24620         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24621         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
24622         CHECK_ACCESS(fee_paid_msat_ptr);
24623         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
24624         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
24625         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24626         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
24627         int64_t ret_ref = (uintptr_t)ret_copy;
24628         return ret_ref;
24629 }
24630
24631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
24632         LDKThirtyTwoBytes payment_id_ref;
24633         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24634         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24635         LDKThirtyTwoBytes payment_hash_ref;
24636         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24637         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24638         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24639         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
24640         int64_t ret_ref = (uintptr_t)ret_copy;
24641         return ret_ref;
24642 }
24643
24644 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) {
24645         LDKThirtyTwoBytes payment_id_ref;
24646         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24647         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24648         LDKThirtyTwoBytes payment_hash_ref;
24649         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24650         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24651         LDKCVec_RouteHopZ path_constr;
24652         path_constr.datalen = (*env)->GetArrayLength(env, path);
24653         if (path_constr.datalen > 0)
24654                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24655         else
24656                 path_constr.data = NULL;
24657         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
24658         for (size_t k = 0; k < path_constr.datalen; k++) {
24659                 int64_t path_conv_10 = path_vals[k];
24660                 LDKRouteHop path_conv_10_conv;
24661                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
24662                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
24663                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
24664                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
24665                 path_constr.data[k] = path_conv_10_conv;
24666         }
24667         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
24668         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24669         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
24670         int64_t ret_ref = (uintptr_t)ret_copy;
24671         return ret_ref;
24672 }
24673
24674 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) {
24675         LDKThirtyTwoBytes payment_id_ref;
24676         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24677         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24678         LDKThirtyTwoBytes payment_hash_ref;
24679         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24680         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24681         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
24682         CHECK_ACCESS(network_update_ptr);
24683         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
24684         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
24685         LDKCVec_RouteHopZ path_constr;
24686         path_constr.datalen = (*env)->GetArrayLength(env, path);
24687         if (path_constr.datalen > 0)
24688                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24689         else
24690                 path_constr.data = NULL;
24691         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
24692         for (size_t k = 0; k < path_constr.datalen; k++) {
24693                 int64_t path_conv_10 = path_vals[k];
24694                 LDKRouteHop path_conv_10_conv;
24695                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
24696                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
24697                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
24698                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
24699                 path_constr.data[k] = path_conv_10_conv;
24700         }
24701         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
24702         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
24703         CHECK_ACCESS(short_channel_id_ptr);
24704         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
24705         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
24706         LDKRouteParameters retry_conv;
24707         retry_conv.inner = (void*)(retry & (~1));
24708         retry_conv.is_owned = (retry & 1) || (retry == 0);
24709         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
24710         retry_conv = RouteParameters_clone(&retry_conv);
24711         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24712         *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);
24713         int64_t ret_ref = (uintptr_t)ret_copy;
24714         return ret_ref;
24715 }
24716
24717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1probe_1successful(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_tArray path) {
24718         LDKThirtyTwoBytes payment_id_ref;
24719         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24720         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24721         LDKThirtyTwoBytes payment_hash_ref;
24722         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24723         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24724         LDKCVec_RouteHopZ path_constr;
24725         path_constr.datalen = (*env)->GetArrayLength(env, path);
24726         if (path_constr.datalen > 0)
24727                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24728         else
24729                 path_constr.data = NULL;
24730         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
24731         for (size_t k = 0; k < path_constr.datalen; k++) {
24732                 int64_t path_conv_10 = path_vals[k];
24733                 LDKRouteHop path_conv_10_conv;
24734                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
24735                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
24736                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
24737                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
24738                 path_constr.data[k] = path_conv_10_conv;
24739         }
24740         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
24741         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24742         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_constr);
24743         int64_t ret_ref = (uintptr_t)ret_copy;
24744         return ret_ref;
24745 }
24746
24747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1probe_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_tArray path, int64_t short_channel_id) {
24748         LDKThirtyTwoBytes payment_id_ref;
24749         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24750         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24751         LDKThirtyTwoBytes payment_hash_ref;
24752         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24753         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24754         LDKCVec_RouteHopZ path_constr;
24755         path_constr.datalen = (*env)->GetArrayLength(env, path);
24756         if (path_constr.datalen > 0)
24757                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24758         else
24759                 path_constr.data = NULL;
24760         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
24761         for (size_t k = 0; k < path_constr.datalen; k++) {
24762                 int64_t path_conv_10 = path_vals[k];
24763                 LDKRouteHop path_conv_10_conv;
24764                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
24765                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
24766                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
24767                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
24768                 path_constr.data[k] = path_conv_10_conv;
24769         }
24770         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
24771         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
24772         CHECK_ACCESS(short_channel_id_ptr);
24773         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
24774         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
24775         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24776         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_constr, short_channel_id_conv);
24777         int64_t ret_ref = (uintptr_t)ret_copy;
24778         return ret_ref;
24779 }
24780
24781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
24782         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24783         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
24784         int64_t ret_ref = (uintptr_t)ret_copy;
24785         return ret_ref;
24786 }
24787
24788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
24789         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
24790         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
24791         if (outputs_constr.datalen > 0)
24792                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
24793         else
24794                 outputs_constr.data = NULL;
24795         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
24796         for (size_t b = 0; b < outputs_constr.datalen; b++) {
24797                 int64_t outputs_conv_27 = outputs_vals[b];
24798                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
24799                 CHECK_ACCESS(outputs_conv_27_ptr);
24800                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
24801                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
24802                 outputs_constr.data[b] = outputs_conv_27_conv;
24803         }
24804         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
24805         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24806         *ret_copy = Event_spendable_outputs(outputs_constr);
24807         int64_t ret_ref = (uintptr_t)ret_copy;
24808         return ret_ref;
24809 }
24810
24811 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) {
24812         LDKThirtyTwoBytes prev_channel_id_ref;
24813         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
24814         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
24815         LDKThirtyTwoBytes next_channel_id_ref;
24816         CHECK((*env)->GetArrayLength(env, next_channel_id) == 32);
24817         (*env)->GetByteArrayRegion(env, next_channel_id, 0, 32, next_channel_id_ref.data);
24818         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
24819         CHECK_ACCESS(fee_earned_msat_ptr);
24820         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
24821         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
24822         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24823         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
24824         int64_t ret_ref = (uintptr_t)ret_copy;
24825         return ret_ref;
24826 }
24827
24828 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) {
24829         LDKThirtyTwoBytes channel_id_ref;
24830         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24831         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
24832         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
24833         CHECK_ACCESS(reason_ptr);
24834         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
24835         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
24836         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24837         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
24838         int64_t ret_ref = (uintptr_t)ret_copy;
24839         return ret_ref;
24840 }
24841
24842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
24843         LDKThirtyTwoBytes channel_id_ref;
24844         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24845         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
24846         LDKTransaction transaction_ref;
24847         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
24848         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
24849         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
24850         transaction_ref.data_is_owned = true;
24851         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24852         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
24853         int64_t ret_ref = (uintptr_t)ret_copy;
24854         return ret_ref;
24855 }
24856
24857 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) {
24858         LDKThirtyTwoBytes temporary_channel_id_ref;
24859         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
24860         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
24861         LDKPublicKey counterparty_node_id_ref;
24862         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
24863         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
24864         LDKChannelTypeFeatures channel_type_conv;
24865         channel_type_conv.inner = (void*)(channel_type & (~1));
24866         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
24867         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
24868         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
24869         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24870         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
24871         int64_t ret_ref = (uintptr_t)ret_copy;
24872         return ret_ref;
24873 }
24874
24875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1htlchandling_1failed(JNIEnv *env, jclass clz, int8_tArray prev_channel_id, int64_t failed_next_destination) {
24876         LDKThirtyTwoBytes prev_channel_id_ref;
24877         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
24878         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
24879         void* failed_next_destination_ptr = (void*)(((uintptr_t)failed_next_destination) & ~1);
24880         CHECK_ACCESS(failed_next_destination_ptr);
24881         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
24882         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)(((uintptr_t)failed_next_destination) & ~1));
24883         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24884         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
24885         int64_t ret_ref = (uintptr_t)ret_copy;
24886         return ret_ref;
24887 }
24888
24889 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
24890         LDKEvent* obj_conv = (LDKEvent*)obj;
24891         LDKCVec_u8Z ret_var = Event_write(obj_conv);
24892         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24893         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24894         CVec_u8Z_free(ret_var);
24895         return ret_arr;
24896 }
24897
24898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24899         LDKu8slice ser_ref;
24900         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24901         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24902         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
24903         *ret_conv = Event_read(ser_ref);
24904         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24905         return (int64_t)ret_conv;
24906 }
24907
24908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24909         if ((this_ptr & 1) != 0) return;
24910         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24911         CHECK_ACCESS(this_ptr_ptr);
24912         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
24913         FREE((void*)this_ptr);
24914         MessageSendEvent_free(this_ptr_conv);
24915 }
24916
24917 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
24918         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24919         *ret_copy = MessageSendEvent_clone(arg);
24920 int64_t ret_ref = (uintptr_t)ret_copy;
24921         return ret_ref;
24922 }
24923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24924         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
24925         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
24926         return ret_conv;
24927 }
24928
24929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24930         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
24931         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24932         *ret_copy = MessageSendEvent_clone(orig_conv);
24933         int64_t ret_ref = (uintptr_t)ret_copy;
24934         return ret_ref;
24935 }
24936
24937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24938         LDKPublicKey node_id_ref;
24939         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24940         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24941         LDKAcceptChannel msg_conv;
24942         msg_conv.inner = (void*)(msg & (~1));
24943         msg_conv.is_owned = (msg & 1) || (msg == 0);
24944         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24945         msg_conv = AcceptChannel_clone(&msg_conv);
24946         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24947         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
24948         int64_t ret_ref = (uintptr_t)ret_copy;
24949         return ret_ref;
24950 }
24951
24952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24953         LDKPublicKey node_id_ref;
24954         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24955         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24956         LDKOpenChannel msg_conv;
24957         msg_conv.inner = (void*)(msg & (~1));
24958         msg_conv.is_owned = (msg & 1) || (msg == 0);
24959         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24960         msg_conv = OpenChannel_clone(&msg_conv);
24961         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24962         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
24963         int64_t ret_ref = (uintptr_t)ret_copy;
24964         return ret_ref;
24965 }
24966
24967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24968         LDKPublicKey node_id_ref;
24969         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24970         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24971         LDKFundingCreated msg_conv;
24972         msg_conv.inner = (void*)(msg & (~1));
24973         msg_conv.is_owned = (msg & 1) || (msg == 0);
24974         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24975         msg_conv = FundingCreated_clone(&msg_conv);
24976         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24977         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
24978         int64_t ret_ref = (uintptr_t)ret_copy;
24979         return ret_ref;
24980 }
24981
24982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24983         LDKPublicKey node_id_ref;
24984         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24985         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24986         LDKFundingSigned msg_conv;
24987         msg_conv.inner = (void*)(msg & (~1));
24988         msg_conv.is_owned = (msg & 1) || (msg == 0);
24989         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24990         msg_conv = FundingSigned_clone(&msg_conv);
24991         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24992         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
24993         int64_t ret_ref = (uintptr_t)ret_copy;
24994         return ret_ref;
24995 }
24996
24997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1ready(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24998         LDKPublicKey node_id_ref;
24999         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25000         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25001         LDKChannelReady msg_conv;
25002         msg_conv.inner = (void*)(msg & (~1));
25003         msg_conv.is_owned = (msg & 1) || (msg == 0);
25004         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25005         msg_conv = ChannelReady_clone(&msg_conv);
25006         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25007         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
25008         int64_t ret_ref = (uintptr_t)ret_copy;
25009         return ret_ref;
25010 }
25011
25012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25013         LDKPublicKey node_id_ref;
25014         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25015         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25016         LDKAnnouncementSignatures msg_conv;
25017         msg_conv.inner = (void*)(msg & (~1));
25018         msg_conv.is_owned = (msg & 1) || (msg == 0);
25019         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25020         msg_conv = AnnouncementSignatures_clone(&msg_conv);
25021         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25022         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
25023         int64_t ret_ref = (uintptr_t)ret_copy;
25024         return ret_ref;
25025 }
25026
25027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
25028         LDKPublicKey node_id_ref;
25029         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25030         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25031         LDKCommitmentUpdate updates_conv;
25032         updates_conv.inner = (void*)(updates & (~1));
25033         updates_conv.is_owned = (updates & 1) || (updates == 0);
25034         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
25035         updates_conv = CommitmentUpdate_clone(&updates_conv);
25036         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25037         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
25038         int64_t ret_ref = (uintptr_t)ret_copy;
25039         return ret_ref;
25040 }
25041
25042 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) {
25043         LDKPublicKey node_id_ref;
25044         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25045         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25046         LDKRevokeAndACK msg_conv;
25047         msg_conv.inner = (void*)(msg & (~1));
25048         msg_conv.is_owned = (msg & 1) || (msg == 0);
25049         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25050         msg_conv = RevokeAndACK_clone(&msg_conv);
25051         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25052         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
25053         int64_t ret_ref = (uintptr_t)ret_copy;
25054         return ret_ref;
25055 }
25056
25057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25058         LDKPublicKey node_id_ref;
25059         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25060         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25061         LDKClosingSigned msg_conv;
25062         msg_conv.inner = (void*)(msg & (~1));
25063         msg_conv.is_owned = (msg & 1) || (msg == 0);
25064         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25065         msg_conv = ClosingSigned_clone(&msg_conv);
25066         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25067         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
25068         int64_t ret_ref = (uintptr_t)ret_copy;
25069         return ret_ref;
25070 }
25071
25072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25073         LDKPublicKey node_id_ref;
25074         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25075         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25076         LDKShutdown msg_conv;
25077         msg_conv.inner = (void*)(msg & (~1));
25078         msg_conv.is_owned = (msg & 1) || (msg == 0);
25079         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25080         msg_conv = Shutdown_clone(&msg_conv);
25081         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25082         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
25083         int64_t ret_ref = (uintptr_t)ret_copy;
25084         return ret_ref;
25085 }
25086
25087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25088         LDKPublicKey node_id_ref;
25089         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25090         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25091         LDKChannelReestablish msg_conv;
25092         msg_conv.inner = (void*)(msg & (~1));
25093         msg_conv.is_owned = (msg & 1) || (msg == 0);
25094         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25095         msg_conv = ChannelReestablish_clone(&msg_conv);
25096         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25097         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
25098         int64_t ret_ref = (uintptr_t)ret_copy;
25099         return ret_ref;
25100 }
25101
25102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
25103         LDKChannelAnnouncement msg_conv;
25104         msg_conv.inner = (void*)(msg & (~1));
25105         msg_conv.is_owned = (msg & 1) || (msg == 0);
25106         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25107         msg_conv = ChannelAnnouncement_clone(&msg_conv);
25108         LDKChannelUpdate update_msg_conv;
25109         update_msg_conv.inner = (void*)(update_msg & (~1));
25110         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
25111         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
25112         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
25113         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25114         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
25115         int64_t ret_ref = (uintptr_t)ret_copy;
25116         return ret_ref;
25117 }
25118
25119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
25120         LDKNodeAnnouncement msg_conv;
25121         msg_conv.inner = (void*)(msg & (~1));
25122         msg_conv.is_owned = (msg & 1) || (msg == 0);
25123         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25124         msg_conv = NodeAnnouncement_clone(&msg_conv);
25125         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25126         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
25127         int64_t ret_ref = (uintptr_t)ret_copy;
25128         return ret_ref;
25129 }
25130
25131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
25132         LDKChannelUpdate msg_conv;
25133         msg_conv.inner = (void*)(msg & (~1));
25134         msg_conv.is_owned = (msg & 1) || (msg == 0);
25135         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25136         msg_conv = ChannelUpdate_clone(&msg_conv);
25137         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25138         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
25139         int64_t ret_ref = (uintptr_t)ret_copy;
25140         return ret_ref;
25141 }
25142
25143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25144         LDKPublicKey node_id_ref;
25145         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25146         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25147         LDKChannelUpdate msg_conv;
25148         msg_conv.inner = (void*)(msg & (~1));
25149         msg_conv.is_owned = (msg & 1) || (msg == 0);
25150         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25151         msg_conv = ChannelUpdate_clone(&msg_conv);
25152         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25153         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
25154         int64_t ret_ref = (uintptr_t)ret_copy;
25155         return ret_ref;
25156 }
25157
25158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
25159         LDKPublicKey node_id_ref;
25160         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25161         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25162         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
25163         CHECK_ACCESS(action_ptr);
25164         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
25165         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
25166         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25167         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
25168         int64_t ret_ref = (uintptr_t)ret_copy;
25169         return ret_ref;
25170 }
25171
25172 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) {
25173         LDKPublicKey node_id_ref;
25174         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25175         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25176         LDKQueryChannelRange msg_conv;
25177         msg_conv.inner = (void*)(msg & (~1));
25178         msg_conv.is_owned = (msg & 1) || (msg == 0);
25179         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25180         msg_conv = QueryChannelRange_clone(&msg_conv);
25181         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25182         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
25183         int64_t ret_ref = (uintptr_t)ret_copy;
25184         return ret_ref;
25185 }
25186
25187 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) {
25188         LDKPublicKey node_id_ref;
25189         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25190         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25191         LDKQueryShortChannelIds msg_conv;
25192         msg_conv.inner = (void*)(msg & (~1));
25193         msg_conv.is_owned = (msg & 1) || (msg == 0);
25194         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25195         msg_conv = QueryShortChannelIds_clone(&msg_conv);
25196         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25197         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
25198         int64_t ret_ref = (uintptr_t)ret_copy;
25199         return ret_ref;
25200 }
25201
25202 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) {
25203         LDKPublicKey node_id_ref;
25204         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25205         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25206         LDKReplyChannelRange msg_conv;
25207         msg_conv.inner = (void*)(msg & (~1));
25208         msg_conv.is_owned = (msg & 1) || (msg == 0);
25209         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25210         msg_conv = ReplyChannelRange_clone(&msg_conv);
25211         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25212         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
25213         int64_t ret_ref = (uintptr_t)ret_copy;
25214         return ret_ref;
25215 }
25216
25217 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) {
25218         LDKPublicKey node_id_ref;
25219         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25220         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25221         LDKGossipTimestampFilter msg_conv;
25222         msg_conv.inner = (void*)(msg & (~1));
25223         msg_conv.is_owned = (msg & 1) || (msg == 0);
25224         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25225         msg_conv = GossipTimestampFilter_clone(&msg_conv);
25226         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25227         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
25228         int64_t ret_ref = (uintptr_t)ret_copy;
25229         return ret_ref;
25230 }
25231
25232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25233         if ((this_ptr & 1) != 0) return;
25234         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25235         CHECK_ACCESS(this_ptr_ptr);
25236         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
25237         FREE((void*)this_ptr);
25238         MessageSendEventsProvider_free(this_ptr_conv);
25239 }
25240
25241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25242         if ((this_ptr & 1) != 0) return;
25243         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25244         CHECK_ACCESS(this_ptr_ptr);
25245         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
25246         FREE((void*)this_ptr);
25247         EventsProvider_free(this_ptr_conv);
25248 }
25249
25250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25251         if ((this_ptr & 1) != 0) return;
25252         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25253         CHECK_ACCESS(this_ptr_ptr);
25254         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
25255         FREE((void*)this_ptr);
25256         EventHandler_free(this_ptr_conv);
25257 }
25258
25259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25260         if ((this_ptr & 1) != 0) return;
25261         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25262         CHECK_ACCESS(this_ptr_ptr);
25263         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
25264         FREE((void*)this_ptr);
25265         APIError_free(this_ptr_conv);
25266 }
25267
25268 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
25269         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25270         *ret_copy = APIError_clone(arg);
25271 int64_t ret_ref = (uintptr_t)ret_copy;
25272         return ret_ref;
25273 }
25274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25275         LDKAPIError* arg_conv = (LDKAPIError*)arg;
25276         int64_t ret_conv = APIError_clone_ptr(arg_conv);
25277         return ret_conv;
25278 }
25279
25280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25281         LDKAPIError* orig_conv = (LDKAPIError*)orig;
25282         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25283         *ret_copy = APIError_clone(orig_conv);
25284         int64_t ret_ref = (uintptr_t)ret_copy;
25285         return ret_ref;
25286 }
25287
25288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
25289         LDKStr err_conv = java_to_owned_str(env, err);
25290         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25291         *ret_copy = APIError_apimisuse_error(err_conv);
25292         int64_t ret_ref = (uintptr_t)ret_copy;
25293         return ret_ref;
25294 }
25295
25296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
25297         LDKStr err_conv = java_to_owned_str(env, err);
25298         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25299         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
25300         int64_t ret_ref = (uintptr_t)ret_copy;
25301         return ret_ref;
25302 }
25303
25304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
25305         LDKStr err_conv = java_to_owned_str(env, err);
25306         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25307         *ret_copy = APIError_route_error(err_conv);
25308         int64_t ret_ref = (uintptr_t)ret_copy;
25309         return ret_ref;
25310 }
25311
25312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
25313         LDKStr err_conv = java_to_owned_str(env, err);
25314         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25315         *ret_copy = APIError_channel_unavailable(err_conv);
25316         int64_t ret_ref = (uintptr_t)ret_copy;
25317         return ret_ref;
25318 }
25319
25320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
25321         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25322         *ret_copy = APIError_monitor_update_failed();
25323         int64_t ret_ref = (uintptr_t)ret_copy;
25324         return ret_ref;
25325 }
25326
25327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
25328         LDKShutdownScript script_conv;
25329         script_conv.inner = (void*)(script & (~1));
25330         script_conv.is_owned = (script & 1) || (script == 0);
25331         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
25332         script_conv = ShutdownScript_clone(&script_conv);
25333         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25334         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
25335         int64_t ret_ref = (uintptr_t)ret_copy;
25336         return ret_ref;
25337 }
25338
25339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25340         LDKBigSize this_obj_conv;
25341         this_obj_conv.inner = (void*)(this_obj & (~1));
25342         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25344         BigSize_free(this_obj_conv);
25345 }
25346
25347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
25348         LDKBigSize this_ptr_conv;
25349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25350         this_ptr_conv.is_owned = false;
25351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25352         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
25353         return ret_conv;
25354 }
25355
25356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25357         LDKBigSize this_ptr_conv;
25358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25359         this_ptr_conv.is_owned = false;
25360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25361         BigSize_set_a(&this_ptr_conv, val);
25362 }
25363
25364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
25365         LDKBigSize ret_var = BigSize_new(a_arg);
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 void JNICALL Java_org_ldk_impl_bindings_Hostname_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25378         LDKHostname this_obj_conv;
25379         this_obj_conv.inner = (void*)(this_obj & (~1));
25380         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25382         Hostname_free(this_obj_conv);
25383 }
25384
25385 static inline uintptr_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
25386         LDKHostname ret_var = Hostname_clone(arg);
25387 int64_t ret_ref = 0;
25388 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25389 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25390 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25391 ret_ref = (uintptr_t)ret_var.inner;
25392 if (ret_var.is_owned) {
25393         ret_ref |= 1;
25394 }
25395         return ret_ref;
25396 }
25397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25398         LDKHostname arg_conv;
25399         arg_conv.inner = (void*)(arg & (~1));
25400         arg_conv.is_owned = false;
25401         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25402         int64_t ret_conv = Hostname_clone_ptr(&arg_conv);
25403         return ret_conv;
25404 }
25405
25406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25407         LDKHostname orig_conv;
25408         orig_conv.inner = (void*)(orig & (~1));
25409         orig_conv.is_owned = false;
25410         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25411         LDKHostname ret_var = Hostname_clone(&orig_conv);
25412         int64_t ret_ref = 0;
25413         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25414         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25416         ret_ref = (uintptr_t)ret_var.inner;
25417         if (ret_var.is_owned) {
25418                 ret_ref |= 1;
25419         }
25420         return ret_ref;
25421 }
25422
25423 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_Hostname_1len(JNIEnv *env, jclass clz, int64_t this_arg) {
25424         LDKHostname this_arg_conv;
25425         this_arg_conv.inner = (void*)(this_arg & (~1));
25426         this_arg_conv.is_owned = false;
25427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25428         int8_t ret_conv = Hostname_len(&this_arg_conv);
25429         return ret_conv;
25430 }
25431
25432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
25433         LDKu8slice msg_ref;
25434         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
25435         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
25436         unsigned char sk_arr[32];
25437         CHECK((*env)->GetArrayLength(env, sk) == 32);
25438         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
25439         unsigned char (*sk_ref)[32] = &sk_arr;
25440         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
25441         *ret_conv = sign(msg_ref, sk_ref);
25442         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
25443         return (int64_t)ret_conv;
25444 }
25445
25446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
25447         LDKu8slice msg_ref;
25448         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
25449         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
25450         LDKStr sig_conv = java_to_owned_str(env, sig);
25451         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
25452         *ret_conv = recover_pk(msg_ref, sig_conv);
25453         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
25454         return (int64_t)ret_conv;
25455 }
25456
25457 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
25458         LDKu8slice msg_ref;
25459         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
25460         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
25461         LDKStr sig_conv = java_to_owned_str(env, sig);
25462         LDKPublicKey pk_ref;
25463         CHECK((*env)->GetArrayLength(env, pk) == 33);
25464         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
25465         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
25466         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
25467         return ret_conv;
25468 }
25469
25470 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
25471         LDKu8slice hrp_bytes_ref;
25472         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
25473         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
25474         LDKCVec_u5Z data_without_signature_constr;
25475         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
25476         if (data_without_signature_constr.datalen > 0)
25477                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
25478         else
25479                 data_without_signature_constr.data = NULL;
25480         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
25481         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
25482                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
25483                 
25484                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
25485         }
25486         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
25487         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
25488         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25489         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25490         CVec_u8Z_free(ret_var);
25491         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
25492         return ret_arr;
25493 }
25494
25495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25496         if ((this_ptr & 1) != 0) return;
25497         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25498         CHECK_ACCESS(this_ptr_ptr);
25499         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
25500         FREE((void*)this_ptr);
25501         Persister_free(this_ptr_conv);
25502 }
25503
25504 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25505         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
25506         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
25507         return ret_conv;
25508 }
25509
25510 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
25511         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
25512         return ret_conv;
25513 }
25514
25515 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
25516         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
25517         return ret_conv;
25518 }
25519
25520 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
25521         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
25522         return ret_conv;
25523 }
25524
25525 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
25526         jclass ret_conv = LDKLevel_to_java(env, Level_info());
25527         return ret_conv;
25528 }
25529
25530 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
25531         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
25532         return ret_conv;
25533 }
25534
25535 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
25536         jclass ret_conv = LDKLevel_to_java(env, Level_error());
25537         return ret_conv;
25538 }
25539
25540 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25541         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
25542         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
25543         jboolean ret_conv = Level_eq(a_conv, b_conv);
25544         return ret_conv;
25545 }
25546
25547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
25548         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
25549         int64_t ret_conv = Level_hash(o_conv);
25550         return ret_conv;
25551 }
25552
25553 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
25554         jclass ret_conv = LDKLevel_to_java(env, Level_max());
25555         return ret_conv;
25556 }
25557
25558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25559         LDKRecord this_obj_conv;
25560         this_obj_conv.inner = (void*)(this_obj & (~1));
25561         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25563         Record_free(this_obj_conv);
25564 }
25565
25566 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
25567         LDKRecord this_ptr_conv;
25568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25569         this_ptr_conv.is_owned = false;
25570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25571         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
25572         return ret_conv;
25573 }
25574
25575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
25576         LDKRecord this_ptr_conv;
25577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25578         this_ptr_conv.is_owned = false;
25579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25580         LDKLevel val_conv = LDKLevel_from_java(env, val);
25581         Record_set_level(&this_ptr_conv, val_conv);
25582 }
25583
25584 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
25585         LDKRecord this_ptr_conv;
25586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25587         this_ptr_conv.is_owned = false;
25588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25589         LDKStr ret_str = Record_get_args(&this_ptr_conv);
25590         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25591         Str_free(ret_str);
25592         return ret_conv;
25593 }
25594
25595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
25596         LDKRecord this_ptr_conv;
25597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25598         this_ptr_conv.is_owned = false;
25599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25600         LDKStr val_conv = java_to_owned_str(env, val);
25601         Record_set_args(&this_ptr_conv, val_conv);
25602 }
25603
25604 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
25605         LDKRecord this_ptr_conv;
25606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25607         this_ptr_conv.is_owned = false;
25608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25609         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
25610         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25611         Str_free(ret_str);
25612         return ret_conv;
25613 }
25614
25615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
25616         LDKRecord this_ptr_conv;
25617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25618         this_ptr_conv.is_owned = false;
25619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25620         LDKStr val_conv = java_to_owned_str(env, val);
25621         Record_set_module_path(&this_ptr_conv, val_conv);
25622 }
25623
25624 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
25625         LDKRecord this_ptr_conv;
25626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25627         this_ptr_conv.is_owned = false;
25628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25629         LDKStr ret_str = Record_get_file(&this_ptr_conv);
25630         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25631         Str_free(ret_str);
25632         return ret_conv;
25633 }
25634
25635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
25636         LDKRecord this_ptr_conv;
25637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25638         this_ptr_conv.is_owned = false;
25639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25640         LDKStr val_conv = java_to_owned_str(env, val);
25641         Record_set_file(&this_ptr_conv, val_conv);
25642 }
25643
25644 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
25645         LDKRecord this_ptr_conv;
25646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25647         this_ptr_conv.is_owned = false;
25648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25649         int32_t ret_conv = Record_get_line(&this_ptr_conv);
25650         return ret_conv;
25651 }
25652
25653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25654         LDKRecord this_ptr_conv;
25655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25656         this_ptr_conv.is_owned = false;
25657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25658         Record_set_line(&this_ptr_conv, val);
25659 }
25660
25661 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
25662         LDKRecord ret_var = Record_clone(arg);
25663 int64_t ret_ref = 0;
25664 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25665 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25666 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25667 ret_ref = (uintptr_t)ret_var.inner;
25668 if (ret_var.is_owned) {
25669         ret_ref |= 1;
25670 }
25671         return ret_ref;
25672 }
25673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25674         LDKRecord arg_conv;
25675         arg_conv.inner = (void*)(arg & (~1));
25676         arg_conv.is_owned = false;
25677         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25678         int64_t ret_conv = Record_clone_ptr(&arg_conv);
25679         return ret_conv;
25680 }
25681
25682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25683         LDKRecord orig_conv;
25684         orig_conv.inner = (void*)(orig & (~1));
25685         orig_conv.is_owned = false;
25686         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25687         LDKRecord ret_var = Record_clone(&orig_conv);
25688         int64_t ret_ref = 0;
25689         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25690         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25692         ret_ref = (uintptr_t)ret_var.inner;
25693         if (ret_var.is_owned) {
25694                 ret_ref |= 1;
25695         }
25696         return ret_ref;
25697 }
25698
25699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25700         if ((this_ptr & 1) != 0) return;
25701         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25702         CHECK_ACCESS(this_ptr_ptr);
25703         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
25704         FREE((void*)this_ptr);
25705         Logger_free(this_ptr_conv);
25706 }
25707
25708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25709         LDKChannelHandshakeConfig this_obj_conv;
25710         this_obj_conv.inner = (void*)(this_obj & (~1));
25711         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25713         ChannelHandshakeConfig_free(this_obj_conv);
25714 }
25715
25716 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
25717         LDKChannelHandshakeConfig this_ptr_conv;
25718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25719         this_ptr_conv.is_owned = false;
25720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25721         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
25722         return ret_conv;
25723 }
25724
25725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25726         LDKChannelHandshakeConfig this_ptr_conv;
25727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25728         this_ptr_conv.is_owned = false;
25729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25730         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
25731 }
25732
25733 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
25734         LDKChannelHandshakeConfig this_ptr_conv;
25735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25736         this_ptr_conv.is_owned = false;
25737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25738         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
25739         return ret_conv;
25740 }
25741
25742 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) {
25743         LDKChannelHandshakeConfig this_ptr_conv;
25744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25745         this_ptr_conv.is_owned = false;
25746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25747         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
25748 }
25749
25750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25751         LDKChannelHandshakeConfig this_ptr_conv;
25752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25753         this_ptr_conv.is_owned = false;
25754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25755         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
25756         return ret_conv;
25757 }
25758
25759 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) {
25760         LDKChannelHandshakeConfig this_ptr_conv;
25761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25762         this_ptr_conv.is_owned = false;
25763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25764         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
25765 }
25766
25767 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) {
25768         LDKChannelHandshakeConfig this_ptr_conv;
25769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25770         this_ptr_conv.is_owned = false;
25771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25772         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
25773         return ret_conv;
25774 }
25775
25776 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) {
25777         LDKChannelHandshakeConfig this_ptr_conv;
25778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25779         this_ptr_conv.is_owned = false;
25780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25781         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
25782 }
25783
25784 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
25785         LDKChannelHandshakeConfig this_ptr_conv;
25786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25787         this_ptr_conv.is_owned = false;
25788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25789         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
25790         return ret_conv;
25791 }
25792
25793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25794         LDKChannelHandshakeConfig this_ptr_conv;
25795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25796         this_ptr_conv.is_owned = false;
25797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25798         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
25799 }
25800
25801 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
25802         LDKChannelHandshakeConfig this_ptr_conv;
25803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25804         this_ptr_conv.is_owned = false;
25805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25806         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
25807         return ret_conv;
25808 }
25809
25810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25811         LDKChannelHandshakeConfig this_ptr_conv;
25812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25813         this_ptr_conv.is_owned = false;
25814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25815         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
25816 }
25817
25818 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
25819         LDKChannelHandshakeConfig this_ptr_conv;
25820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25821         this_ptr_conv.is_owned = false;
25822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25823         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
25824         return ret_conv;
25825 }
25826
25827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25828         LDKChannelHandshakeConfig this_ptr_conv;
25829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25830         this_ptr_conv.is_owned = false;
25831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25832         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
25833 }
25834
25835 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, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
25836         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, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
25837         int64_t ret_ref = 0;
25838         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25839         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25841         ret_ref = (uintptr_t)ret_var.inner;
25842         if (ret_var.is_owned) {
25843                 ret_ref |= 1;
25844         }
25845         return ret_ref;
25846 }
25847
25848 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
25849         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
25850 int64_t ret_ref = 0;
25851 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25852 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25853 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25854 ret_ref = (uintptr_t)ret_var.inner;
25855 if (ret_var.is_owned) {
25856         ret_ref |= 1;
25857 }
25858         return ret_ref;
25859 }
25860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25861         LDKChannelHandshakeConfig arg_conv;
25862         arg_conv.inner = (void*)(arg & (~1));
25863         arg_conv.is_owned = false;
25864         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25865         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
25866         return ret_conv;
25867 }
25868
25869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25870         LDKChannelHandshakeConfig orig_conv;
25871         orig_conv.inner = (void*)(orig & (~1));
25872         orig_conv.is_owned = false;
25873         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25874         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
25875         int64_t ret_ref = 0;
25876         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25877         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25879         ret_ref = (uintptr_t)ret_var.inner;
25880         if (ret_var.is_owned) {
25881                 ret_ref |= 1;
25882         }
25883         return ret_ref;
25884 }
25885
25886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
25887         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
25888         int64_t ret_ref = 0;
25889         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25890         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25892         ret_ref = (uintptr_t)ret_var.inner;
25893         if (ret_var.is_owned) {
25894                 ret_ref |= 1;
25895         }
25896         return ret_ref;
25897 }
25898
25899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25900         LDKChannelHandshakeLimits this_obj_conv;
25901         this_obj_conv.inner = (void*)(this_obj & (~1));
25902         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25904         ChannelHandshakeLimits_free(this_obj_conv);
25905 }
25906
25907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25908         LDKChannelHandshakeLimits this_ptr_conv;
25909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25910         this_ptr_conv.is_owned = false;
25911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25912         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
25913         return ret_conv;
25914 }
25915
25916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25917         LDKChannelHandshakeLimits this_ptr_conv;
25918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25919         this_ptr_conv.is_owned = false;
25920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25921         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
25922 }
25923
25924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25925         LDKChannelHandshakeLimits this_ptr_conv;
25926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25927         this_ptr_conv.is_owned = false;
25928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25929         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
25930         return ret_conv;
25931 }
25932
25933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25934         LDKChannelHandshakeLimits this_ptr_conv;
25935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25936         this_ptr_conv.is_owned = false;
25937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25938         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
25939 }
25940
25941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25942         LDKChannelHandshakeLimits this_ptr_conv;
25943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25944         this_ptr_conv.is_owned = false;
25945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25946         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
25947         return ret_conv;
25948 }
25949
25950 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) {
25951         LDKChannelHandshakeLimits this_ptr_conv;
25952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25953         this_ptr_conv.is_owned = false;
25954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25955         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
25956 }
25957
25958 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) {
25959         LDKChannelHandshakeLimits this_ptr_conv;
25960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25961         this_ptr_conv.is_owned = false;
25962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25963         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
25964         return ret_conv;
25965 }
25966
25967 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) {
25968         LDKChannelHandshakeLimits this_ptr_conv;
25969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25970         this_ptr_conv.is_owned = false;
25971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25972         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
25973 }
25974
25975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25976         LDKChannelHandshakeLimits this_ptr_conv;
25977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25978         this_ptr_conv.is_owned = false;
25979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25980         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
25981         return ret_conv;
25982 }
25983
25984 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) {
25985         LDKChannelHandshakeLimits this_ptr_conv;
25986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25987         this_ptr_conv.is_owned = false;
25988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25989         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
25990 }
25991
25992 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
25993         LDKChannelHandshakeLimits this_ptr_conv;
25994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25995         this_ptr_conv.is_owned = false;
25996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25997         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
25998         return ret_conv;
25999 }
26000
26001 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) {
26002         LDKChannelHandshakeLimits this_ptr_conv;
26003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26004         this_ptr_conv.is_owned = false;
26005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26006         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
26007 }
26008
26009 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
26010         LDKChannelHandshakeLimits this_ptr_conv;
26011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26012         this_ptr_conv.is_owned = false;
26013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26014         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
26015         return ret_conv;
26016 }
26017
26018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26019         LDKChannelHandshakeLimits this_ptr_conv;
26020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26021         this_ptr_conv.is_owned = false;
26022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26023         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
26024 }
26025
26026 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr) {
26027         LDKChannelHandshakeLimits this_ptr_conv;
26028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26029         this_ptr_conv.is_owned = false;
26030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26031         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
26032         return ret_conv;
26033 }
26034
26035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26036         LDKChannelHandshakeLimits this_ptr_conv;
26037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26038         this_ptr_conv.is_owned = false;
26039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26040         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
26041 }
26042
26043 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
26044         LDKChannelHandshakeLimits this_ptr_conv;
26045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26046         this_ptr_conv.is_owned = false;
26047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26048         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
26049         return ret_conv;
26050 }
26051
26052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26053         LDKChannelHandshakeLimits this_ptr_conv;
26054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26055         this_ptr_conv.is_owned = false;
26056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26057         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
26058 }
26059
26060 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26061         LDKChannelHandshakeLimits this_ptr_conv;
26062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26063         this_ptr_conv.is_owned = false;
26064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26065         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
26066         return ret_conv;
26067 }
26068
26069 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) {
26070         LDKChannelHandshakeLimits this_ptr_conv;
26071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26072         this_ptr_conv.is_owned = false;
26073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26074         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
26075 }
26076
26077 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) {
26078         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);
26079         int64_t ret_ref = 0;
26080         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26081         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26083         ret_ref = (uintptr_t)ret_var.inner;
26084         if (ret_var.is_owned) {
26085                 ret_ref |= 1;
26086         }
26087         return ret_ref;
26088 }
26089
26090 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
26091         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
26092 int64_t ret_ref = 0;
26093 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26094 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26095 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26096 ret_ref = (uintptr_t)ret_var.inner;
26097 if (ret_var.is_owned) {
26098         ret_ref |= 1;
26099 }
26100         return ret_ref;
26101 }
26102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26103         LDKChannelHandshakeLimits arg_conv;
26104         arg_conv.inner = (void*)(arg & (~1));
26105         arg_conv.is_owned = false;
26106         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26107         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
26108         return ret_conv;
26109 }
26110
26111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26112         LDKChannelHandshakeLimits orig_conv;
26113         orig_conv.inner = (void*)(orig & (~1));
26114         orig_conv.is_owned = false;
26115         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26116         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
26117         int64_t ret_ref = 0;
26118         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26119         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26121         ret_ref = (uintptr_t)ret_var.inner;
26122         if (ret_var.is_owned) {
26123                 ret_ref |= 1;
26124         }
26125         return ret_ref;
26126 }
26127
26128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
26129         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
26130         int64_t ret_ref = 0;
26131         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26132         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26134         ret_ref = (uintptr_t)ret_var.inner;
26135         if (ret_var.is_owned) {
26136                 ret_ref |= 1;
26137         }
26138         return ret_ref;
26139 }
26140
26141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26142         LDKChannelConfig this_obj_conv;
26143         this_obj_conv.inner = (void*)(this_obj & (~1));
26144         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26146         ChannelConfig_free(this_obj_conv);
26147 }
26148
26149 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
26150         LDKChannelConfig this_ptr_conv;
26151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26152         this_ptr_conv.is_owned = false;
26153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26154         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
26155         return ret_conv;
26156 }
26157
26158 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) {
26159         LDKChannelConfig this_ptr_conv;
26160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26161         this_ptr_conv.is_owned = false;
26162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26163         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
26164 }
26165
26166 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26167         LDKChannelConfig this_ptr_conv;
26168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26169         this_ptr_conv.is_owned = false;
26170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26171         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
26172         return ret_conv;
26173 }
26174
26175 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) {
26176         LDKChannelConfig this_ptr_conv;
26177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26178         this_ptr_conv.is_owned = false;
26179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26180         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
26181 }
26182
26183 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
26184         LDKChannelConfig this_ptr_conv;
26185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26186         this_ptr_conv.is_owned = false;
26187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26188         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
26189         return ret_conv;
26190 }
26191
26192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26193         LDKChannelConfig this_ptr_conv;
26194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26195         this_ptr_conv.is_owned = false;
26196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26197         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
26198 }
26199
26200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26201         LDKChannelConfig this_ptr_conv;
26202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26203         this_ptr_conv.is_owned = false;
26204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26205         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
26206         return ret_conv;
26207 }
26208
26209 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) {
26210         LDKChannelConfig this_ptr_conv;
26211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26212         this_ptr_conv.is_owned = false;
26213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26214         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
26215 }
26216
26217 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) {
26218         LDKChannelConfig this_ptr_conv;
26219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26220         this_ptr_conv.is_owned = false;
26221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26222         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
26223         return ret_conv;
26224 }
26225
26226 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) {
26227         LDKChannelConfig this_ptr_conv;
26228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26229         this_ptr_conv.is_owned = false;
26230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26231         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
26232 }
26233
26234 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, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
26235         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
26236         int64_t ret_ref = 0;
26237         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26238         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26240         ret_ref = (uintptr_t)ret_var.inner;
26241         if (ret_var.is_owned) {
26242                 ret_ref |= 1;
26243         }
26244         return ret_ref;
26245 }
26246
26247 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
26248         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
26249 int64_t ret_ref = 0;
26250 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26251 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26252 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26253 ret_ref = (uintptr_t)ret_var.inner;
26254 if (ret_var.is_owned) {
26255         ret_ref |= 1;
26256 }
26257         return ret_ref;
26258 }
26259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26260         LDKChannelConfig arg_conv;
26261         arg_conv.inner = (void*)(arg & (~1));
26262         arg_conv.is_owned = false;
26263         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26264         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
26265         return ret_conv;
26266 }
26267
26268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26269         LDKChannelConfig orig_conv;
26270         orig_conv.inner = (void*)(orig & (~1));
26271         orig_conv.is_owned = false;
26272         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26273         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
26274         int64_t ret_ref = 0;
26275         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26276         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26278         ret_ref = (uintptr_t)ret_var.inner;
26279         if (ret_var.is_owned) {
26280                 ret_ref |= 1;
26281         }
26282         return ret_ref;
26283 }
26284
26285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
26286         LDKChannelConfig ret_var = ChannelConfig_default();
26287         int64_t ret_ref = 0;
26288         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26289         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26291         ret_ref = (uintptr_t)ret_var.inner;
26292         if (ret_var.is_owned) {
26293                 ret_ref |= 1;
26294         }
26295         return ret_ref;
26296 }
26297
26298 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
26299         LDKChannelConfig obj_conv;
26300         obj_conv.inner = (void*)(obj & (~1));
26301         obj_conv.is_owned = false;
26302         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26303         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
26304         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26305         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26306         CVec_u8Z_free(ret_var);
26307         return ret_arr;
26308 }
26309
26310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26311         LDKu8slice ser_ref;
26312         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26313         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26314         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
26315         *ret_conv = ChannelConfig_read(ser_ref);
26316         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26317         return (int64_t)ret_conv;
26318 }
26319
26320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26321         LDKUserConfig this_obj_conv;
26322         this_obj_conv.inner = (void*)(this_obj & (~1));
26323         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26325         UserConfig_free(this_obj_conv);
26326 }
26327
26328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
26329         LDKUserConfig this_ptr_conv;
26330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26331         this_ptr_conv.is_owned = false;
26332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26333         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_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 void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26346         LDKUserConfig this_ptr_conv;
26347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26348         this_ptr_conv.is_owned = false;
26349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26350         LDKChannelHandshakeConfig val_conv;
26351         val_conv.inner = (void*)(val & (~1));
26352         val_conv.is_owned = (val & 1) || (val == 0);
26353         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26354         val_conv = ChannelHandshakeConfig_clone(&val_conv);
26355         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
26356 }
26357
26358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
26359         LDKUserConfig this_ptr_conv;
26360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26361         this_ptr_conv.is_owned = false;
26362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26363         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
26364         int64_t ret_ref = 0;
26365         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26366         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26368         ret_ref = (uintptr_t)ret_var.inner;
26369         if (ret_var.is_owned) {
26370                 ret_ref |= 1;
26371         }
26372         return ret_ref;
26373 }
26374
26375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26376         LDKUserConfig this_ptr_conv;
26377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26378         this_ptr_conv.is_owned = false;
26379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26380         LDKChannelHandshakeLimits val_conv;
26381         val_conv.inner = (void*)(val & (~1));
26382         val_conv.is_owned = (val & 1) || (val == 0);
26383         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26384         val_conv = ChannelHandshakeLimits_clone(&val_conv);
26385         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
26386 }
26387
26388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
26389         LDKUserConfig this_ptr_conv;
26390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26391         this_ptr_conv.is_owned = false;
26392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26393         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
26394         int64_t ret_ref = 0;
26395         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26396         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26398         ret_ref = (uintptr_t)ret_var.inner;
26399         if (ret_var.is_owned) {
26400                 ret_ref |= 1;
26401         }
26402         return ret_ref;
26403 }
26404
26405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26406         LDKUserConfig this_ptr_conv;
26407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26408         this_ptr_conv.is_owned = false;
26409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26410         LDKChannelConfig val_conv;
26411         val_conv.inner = (void*)(val & (~1));
26412         val_conv.is_owned = (val & 1) || (val == 0);
26413         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26414         val_conv = ChannelConfig_clone(&val_conv);
26415         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
26416 }
26417
26418 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
26419         LDKUserConfig this_ptr_conv;
26420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26421         this_ptr_conv.is_owned = false;
26422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26423         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
26424         return ret_conv;
26425 }
26426
26427 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) {
26428         LDKUserConfig this_ptr_conv;
26429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26430         this_ptr_conv.is_owned = false;
26431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26432         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
26433 }
26434
26435 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
26436         LDKUserConfig this_ptr_conv;
26437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26438         this_ptr_conv.is_owned = false;
26439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26440         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
26441         return ret_conv;
26442 }
26443
26444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26445         LDKUserConfig this_ptr_conv;
26446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26447         this_ptr_conv.is_owned = false;
26448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26449         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
26450 }
26451
26452 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
26453         LDKUserConfig this_ptr_conv;
26454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26455         this_ptr_conv.is_owned = false;
26456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26457         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
26458         return ret_conv;
26459 }
26460
26461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26462         LDKUserConfig this_ptr_conv;
26463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26464         this_ptr_conv.is_owned = false;
26465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26466         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
26467 }
26468
26469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t channel_handshake_config_arg, int64_t channel_handshake_limits_arg, int64_t channel_config_arg, jboolean accept_forwards_to_priv_channels_arg, jboolean accept_inbound_channels_arg, jboolean manually_accept_inbound_channels_arg) {
26470         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
26471         channel_handshake_config_arg_conv.inner = (void*)(channel_handshake_config_arg & (~1));
26472         channel_handshake_config_arg_conv.is_owned = (channel_handshake_config_arg & 1) || (channel_handshake_config_arg == 0);
26473         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
26474         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
26475         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
26476         channel_handshake_limits_arg_conv.inner = (void*)(channel_handshake_limits_arg & (~1));
26477         channel_handshake_limits_arg_conv.is_owned = (channel_handshake_limits_arg & 1) || (channel_handshake_limits_arg == 0);
26478         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
26479         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
26480         LDKChannelConfig channel_config_arg_conv;
26481         channel_config_arg_conv.inner = (void*)(channel_config_arg & (~1));
26482         channel_config_arg_conv.is_owned = (channel_config_arg & 1) || (channel_config_arg == 0);
26483         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
26484         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
26485         LDKUserConfig ret_var = UserConfig_new(channel_handshake_config_arg_conv, channel_handshake_limits_arg_conv, channel_config_arg_conv, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg, manually_accept_inbound_channels_arg);
26486         int64_t ret_ref = 0;
26487         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26488         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26490         ret_ref = (uintptr_t)ret_var.inner;
26491         if (ret_var.is_owned) {
26492                 ret_ref |= 1;
26493         }
26494         return ret_ref;
26495 }
26496
26497 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
26498         LDKUserConfig ret_var = UserConfig_clone(arg);
26499 int64_t ret_ref = 0;
26500 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26501 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26502 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26503 ret_ref = (uintptr_t)ret_var.inner;
26504 if (ret_var.is_owned) {
26505         ret_ref |= 1;
26506 }
26507         return ret_ref;
26508 }
26509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26510         LDKUserConfig arg_conv;
26511         arg_conv.inner = (void*)(arg & (~1));
26512         arg_conv.is_owned = false;
26513         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26514         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
26515         return ret_conv;
26516 }
26517
26518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26519         LDKUserConfig orig_conv;
26520         orig_conv.inner = (void*)(orig & (~1));
26521         orig_conv.is_owned = false;
26522         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26523         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
26524         int64_t ret_ref = 0;
26525         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26526         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26528         ret_ref = (uintptr_t)ret_var.inner;
26529         if (ret_var.is_owned) {
26530                 ret_ref |= 1;
26531         }
26532         return ret_ref;
26533 }
26534
26535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
26536         LDKUserConfig ret_var = UserConfig_default();
26537         int64_t ret_ref = 0;
26538         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26539         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26541         ret_ref = (uintptr_t)ret_var.inner;
26542         if (ret_var.is_owned) {
26543                 ret_ref |= 1;
26544         }
26545         return ret_ref;
26546 }
26547
26548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26549         LDKBestBlock this_obj_conv;
26550         this_obj_conv.inner = (void*)(this_obj & (~1));
26551         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26553         BestBlock_free(this_obj_conv);
26554 }
26555
26556 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
26557         LDKBestBlock ret_var = BestBlock_clone(arg);
26558 int64_t ret_ref = 0;
26559 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26560 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26561 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26562 ret_ref = (uintptr_t)ret_var.inner;
26563 if (ret_var.is_owned) {
26564         ret_ref |= 1;
26565 }
26566         return ret_ref;
26567 }
26568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26569         LDKBestBlock arg_conv;
26570         arg_conv.inner = (void*)(arg & (~1));
26571         arg_conv.is_owned = false;
26572         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26573         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
26574         return ret_conv;
26575 }
26576
26577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26578         LDKBestBlock orig_conv;
26579         orig_conv.inner = (void*)(orig & (~1));
26580         orig_conv.is_owned = false;
26581         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26582         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
26583         int64_t ret_ref = 0;
26584         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26585         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26587         ret_ref = (uintptr_t)ret_var.inner;
26588         if (ret_var.is_owned) {
26589                 ret_ref |= 1;
26590         }
26591         return ret_ref;
26592 }
26593
26594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
26595         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
26596         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
26597         int64_t ret_ref = 0;
26598         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26599         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26601         ret_ref = (uintptr_t)ret_var.inner;
26602         if (ret_var.is_owned) {
26603                 ret_ref |= 1;
26604         }
26605         return ret_ref;
26606 }
26607
26608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
26609         LDKThirtyTwoBytes block_hash_ref;
26610         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
26611         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
26612         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
26613         int64_t ret_ref = 0;
26614         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26615         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26617         ret_ref = (uintptr_t)ret_var.inner;
26618         if (ret_var.is_owned) {
26619                 ret_ref |= 1;
26620         }
26621         return ret_ref;
26622 }
26623
26624 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
26625         LDKBestBlock this_arg_conv;
26626         this_arg_conv.inner = (void*)(this_arg & (~1));
26627         this_arg_conv.is_owned = false;
26628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26629         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26630         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
26631         return ret_arr;
26632 }
26633
26634 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
26635         LDKBestBlock this_arg_conv;
26636         this_arg_conv.inner = (void*)(this_arg & (~1));
26637         this_arg_conv.is_owned = false;
26638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26639         int32_t ret_conv = BestBlock_height(&this_arg_conv);
26640         return ret_conv;
26641 }
26642
26643 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26644         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
26645         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
26646         return ret_conv;
26647 }
26648
26649 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
26650         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
26651         return ret_conv;
26652 }
26653
26654 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
26655         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
26656         return ret_conv;
26657 }
26658
26659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26660         if ((this_ptr & 1) != 0) return;
26661         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26662         CHECK_ACCESS(this_ptr_ptr);
26663         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
26664         FREE((void*)this_ptr);
26665         Access_free(this_ptr_conv);
26666 }
26667
26668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26669         if ((this_ptr & 1) != 0) return;
26670         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26671         CHECK_ACCESS(this_ptr_ptr);
26672         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
26673         FREE((void*)this_ptr);
26674         Listen_free(this_ptr_conv);
26675 }
26676
26677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26678         if ((this_ptr & 1) != 0) return;
26679         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26680         CHECK_ACCESS(this_ptr_ptr);
26681         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
26682         FREE((void*)this_ptr);
26683         Confirm_free(this_ptr_conv);
26684 }
26685
26686 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26687         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
26688         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
26689         return ret_conv;
26690 }
26691
26692 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
26693         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
26694         return ret_conv;
26695 }
26696
26697 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
26698         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
26699         return ret_conv;
26700 }
26701
26702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26703         if ((this_ptr & 1) != 0) return;
26704         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26705         CHECK_ACCESS(this_ptr_ptr);
26706         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
26707         FREE((void*)this_ptr);
26708         Watch_free(this_ptr_conv);
26709 }
26710
26711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26712         if ((this_ptr & 1) != 0) return;
26713         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26714         CHECK_ACCESS(this_ptr_ptr);
26715         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
26716         FREE((void*)this_ptr);
26717         Filter_free(this_ptr_conv);
26718 }
26719
26720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26721         LDKWatchedOutput this_obj_conv;
26722         this_obj_conv.inner = (void*)(this_obj & (~1));
26723         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26725         WatchedOutput_free(this_obj_conv);
26726 }
26727
26728 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
26729         LDKWatchedOutput this_ptr_conv;
26730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26731         this_ptr_conv.is_owned = false;
26732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26733         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26734         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
26735         return ret_arr;
26736 }
26737
26738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26739         LDKWatchedOutput this_ptr_conv;
26740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26741         this_ptr_conv.is_owned = false;
26742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26743         LDKThirtyTwoBytes val_ref;
26744         CHECK((*env)->GetArrayLength(env, val) == 32);
26745         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26746         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
26747 }
26748
26749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26750         LDKWatchedOutput this_ptr_conv;
26751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26752         this_ptr_conv.is_owned = false;
26753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26754         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
26755         int64_t ret_ref = 0;
26756         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26757         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26759         ret_ref = (uintptr_t)ret_var.inner;
26760         if (ret_var.is_owned) {
26761                 ret_ref |= 1;
26762         }
26763         return ret_ref;
26764 }
26765
26766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26767         LDKWatchedOutput this_ptr_conv;
26768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26769         this_ptr_conv.is_owned = false;
26770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26771         LDKOutPoint val_conv;
26772         val_conv.inner = (void*)(val & (~1));
26773         val_conv.is_owned = (val & 1) || (val == 0);
26774         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26775         val_conv = OutPoint_clone(&val_conv);
26776         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
26777 }
26778
26779 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26780         LDKWatchedOutput this_ptr_conv;
26781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26782         this_ptr_conv.is_owned = false;
26783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26784         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
26785         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26786         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26787         return ret_arr;
26788 }
26789
26790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26791         LDKWatchedOutput this_ptr_conv;
26792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26793         this_ptr_conv.is_owned = false;
26794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26795         LDKCVec_u8Z val_ref;
26796         val_ref.datalen = (*env)->GetArrayLength(env, val);
26797         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
26798         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
26799         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
26800 }
26801
26802 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) {
26803         LDKThirtyTwoBytes block_hash_arg_ref;
26804         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
26805         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
26806         LDKOutPoint outpoint_arg_conv;
26807         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
26808         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
26809         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
26810         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
26811         LDKCVec_u8Z script_pubkey_arg_ref;
26812         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
26813         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
26814         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
26815         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
26816         int64_t ret_ref = 0;
26817         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26818         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26819         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26820         ret_ref = (uintptr_t)ret_var.inner;
26821         if (ret_var.is_owned) {
26822                 ret_ref |= 1;
26823         }
26824         return ret_ref;
26825 }
26826
26827 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
26828         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
26829 int64_t ret_ref = 0;
26830 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26831 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26832 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26833 ret_ref = (uintptr_t)ret_var.inner;
26834 if (ret_var.is_owned) {
26835         ret_ref |= 1;
26836 }
26837         return ret_ref;
26838 }
26839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26840         LDKWatchedOutput arg_conv;
26841         arg_conv.inner = (void*)(arg & (~1));
26842         arg_conv.is_owned = false;
26843         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26844         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
26845         return ret_conv;
26846 }
26847
26848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26849         LDKWatchedOutput orig_conv;
26850         orig_conv.inner = (void*)(orig & (~1));
26851         orig_conv.is_owned = false;
26852         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26853         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
26854         int64_t ret_ref = 0;
26855         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26856         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26858         ret_ref = (uintptr_t)ret_var.inner;
26859         if (ret_var.is_owned) {
26860                 ret_ref |= 1;
26861         }
26862         return ret_ref;
26863 }
26864
26865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
26866         LDKWatchedOutput o_conv;
26867         o_conv.inner = (void*)(o & (~1));
26868         o_conv.is_owned = false;
26869         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26870         int64_t ret_conv = WatchedOutput_hash(&o_conv);
26871         return ret_conv;
26872 }
26873
26874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26875         if ((this_ptr & 1) != 0) return;
26876         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26877         CHECK_ACCESS(this_ptr_ptr);
26878         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
26879         FREE((void*)this_ptr);
26880         BroadcasterInterface_free(this_ptr_conv);
26881 }
26882
26883 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26884         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
26885         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
26886         return ret_conv;
26887 }
26888
26889 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
26890         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
26891         return ret_conv;
26892 }
26893
26894 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
26895         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
26896         return ret_conv;
26897 }
26898
26899 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
26900         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
26901         return ret_conv;
26902 }
26903
26904 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26905         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
26906         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
26907         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
26908         return ret_conv;
26909 }
26910
26911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26912         if ((this_ptr & 1) != 0) return;
26913         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26914         CHECK_ACCESS(this_ptr_ptr);
26915         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
26916         FREE((void*)this_ptr);
26917         FeeEstimator_free(this_ptr_conv);
26918 }
26919
26920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26921         LDKMonitorUpdateId this_obj_conv;
26922         this_obj_conv.inner = (void*)(this_obj & (~1));
26923         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26925         MonitorUpdateId_free(this_obj_conv);
26926 }
26927
26928 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
26929         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
26930 int64_t ret_ref = 0;
26931 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26932 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26933 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26934 ret_ref = (uintptr_t)ret_var.inner;
26935 if (ret_var.is_owned) {
26936         ret_ref |= 1;
26937 }
26938         return ret_ref;
26939 }
26940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26941         LDKMonitorUpdateId arg_conv;
26942         arg_conv.inner = (void*)(arg & (~1));
26943         arg_conv.is_owned = false;
26944         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26945         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
26946         return ret_conv;
26947 }
26948
26949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26950         LDKMonitorUpdateId orig_conv;
26951         orig_conv.inner = (void*)(orig & (~1));
26952         orig_conv.is_owned = false;
26953         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26954         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
26955         int64_t ret_ref = 0;
26956         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26957         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26959         ret_ref = (uintptr_t)ret_var.inner;
26960         if (ret_var.is_owned) {
26961                 ret_ref |= 1;
26962         }
26963         return ret_ref;
26964 }
26965
26966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
26967         LDKMonitorUpdateId o_conv;
26968         o_conv.inner = (void*)(o & (~1));
26969         o_conv.is_owned = false;
26970         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26971         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
26972         return ret_conv;
26973 }
26974
26975 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26976         LDKMonitorUpdateId a_conv;
26977         a_conv.inner = (void*)(a & (~1));
26978         a_conv.is_owned = false;
26979         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26980         LDKMonitorUpdateId b_conv;
26981         b_conv.inner = (void*)(b & (~1));
26982         b_conv.is_owned = false;
26983         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
26984         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
26985         return ret_conv;
26986 }
26987
26988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26989         if ((this_ptr & 1) != 0) return;
26990         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26991         CHECK_ACCESS(this_ptr_ptr);
26992         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
26993         FREE((void*)this_ptr);
26994         Persist_free(this_ptr_conv);
26995 }
26996
26997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26998         LDKLockedChannelMonitor this_obj_conv;
26999         this_obj_conv.inner = (void*)(this_obj & (~1));
27000         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27002         LockedChannelMonitor_free(this_obj_conv);
27003 }
27004
27005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27006         LDKChainMonitor this_obj_conv;
27007         this_obj_conv.inner = (void*)(this_obj & (~1));
27008         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27010         ChainMonitor_free(this_obj_conv);
27011 }
27012
27013 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) {
27014         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
27015         CHECK_ACCESS(chain_source_ptr);
27016         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
27017         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
27018         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
27019                 // Manually implement clone for Java trait instances
27020                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
27021                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27022                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
27023                 }
27024         }
27025         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27026         CHECK_ACCESS(broadcaster_ptr);
27027         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27028         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27029                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27030                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27031         }
27032         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27033         CHECK_ACCESS(logger_ptr);
27034         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27035         if (logger_conv.free == LDKLogger_JCalls_free) {
27036                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27037                 LDKLogger_JCalls_cloned(&logger_conv);
27038         }
27039         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
27040         CHECK_ACCESS(feeest_ptr);
27041         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
27042         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
27043                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27044                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
27045         }
27046         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
27047         CHECK_ACCESS(persister_ptr);
27048         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
27049         if (persister_conv.free == LDKPersist_JCalls_free) {
27050                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27051                 LDKPersist_JCalls_cloned(&persister_conv);
27052         }
27053         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
27054         int64_t ret_ref = 0;
27055         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27056         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27058         ret_ref = (uintptr_t)ret_var.inner;
27059         if (ret_var.is_owned) {
27060                 ret_ref |= 1;
27061         }
27062         return ret_ref;
27063 }
27064
27065 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) {
27066         LDKChainMonitor this_arg_conv;
27067         this_arg_conv.inner = (void*)(this_arg & (~1));
27068         this_arg_conv.is_owned = false;
27069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27070         LDKCVec_ChannelDetailsZ ignored_channels_constr;
27071         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
27072         if (ignored_channels_constr.datalen > 0)
27073                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
27074         else
27075                 ignored_channels_constr.data = NULL;
27076         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
27077         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
27078                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
27079                 LDKChannelDetails ignored_channels_conv_16_conv;
27080                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
27081                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
27082                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
27083                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
27084                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
27085         }
27086         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
27087         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
27088         int64_tArray ret_arr = NULL;
27089         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27090         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27091         for (size_t j = 0; j < ret_var.datalen; j++) {
27092                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27093                 *ret_conv_9_copy = ret_var.data[j];
27094                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
27095                 ret_arr_ptr[j] = ret_conv_9_ref;
27096         }
27097         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27098         FREE(ret_var.data);
27099         return ret_arr;
27100 }
27101
27102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
27103         LDKChainMonitor this_arg_conv;
27104         this_arg_conv.inner = (void*)(this_arg & (~1));
27105         this_arg_conv.is_owned = false;
27106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27107         LDKOutPoint funding_txo_conv;
27108         funding_txo_conv.inner = (void*)(funding_txo & (~1));
27109         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
27110         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
27111         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
27112         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
27113         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
27114         return (int64_t)ret_conv;
27115 }
27116
27117 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
27118         LDKChainMonitor this_arg_conv;
27119         this_arg_conv.inner = (void*)(this_arg & (~1));
27120         this_arg_conv.is_owned = false;
27121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27122         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
27123         int64_tArray ret_arr = NULL;
27124         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27125         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27126         for (size_t k = 0; k < ret_var.datalen; k++) {
27127                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
27128                 int64_t ret_conv_10_ref = 0;
27129                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27130                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27131                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
27132                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
27133                 if (ret_conv_10_var.is_owned) {
27134                         ret_conv_10_ref |= 1;
27135                 }
27136                 ret_arr_ptr[k] = ret_conv_10_ref;
27137         }
27138         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27139         FREE(ret_var.data);
27140         return ret_arr;
27141 }
27142
27143 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) {
27144         LDKChainMonitor this_arg_conv;
27145         this_arg_conv.inner = (void*)(this_arg & (~1));
27146         this_arg_conv.is_owned = false;
27147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27148         LDKOutPoint funding_txo_conv;
27149         funding_txo_conv.inner = (void*)(funding_txo & (~1));
27150         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
27151         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
27152         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
27153         LDKMonitorUpdateId completed_update_id_conv;
27154         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
27155         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
27156         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
27157         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
27158         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27159         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
27160         return (int64_t)ret_conv;
27161 }
27162
27163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
27164         LDKChainMonitor this_arg_conv;
27165         this_arg_conv.inner = (void*)(this_arg & (~1));
27166         this_arg_conv.is_owned = false;
27167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27168         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
27169         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
27170         return (int64_t)ret_ret;
27171 }
27172
27173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
27174         LDKChainMonitor this_arg_conv;
27175         this_arg_conv.inner = (void*)(this_arg & (~1));
27176         this_arg_conv.is_owned = false;
27177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27178         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
27179         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
27180         return (int64_t)ret_ret;
27181 }
27182
27183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
27184         LDKChainMonitor this_arg_conv;
27185         this_arg_conv.inner = (void*)(this_arg & (~1));
27186         this_arg_conv.is_owned = false;
27187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27188         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
27189         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
27190         return (int64_t)ret_ret;
27191 }
27192
27193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
27194         LDKChainMonitor this_arg_conv;
27195         this_arg_conv.inner = (void*)(this_arg & (~1));
27196         this_arg_conv.is_owned = false;
27197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27198         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
27199         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
27200         return (int64_t)ret_ret;
27201 }
27202
27203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27204         LDKChannelMonitorUpdate this_obj_conv;
27205         this_obj_conv.inner = (void*)(this_obj & (~1));
27206         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27208         ChannelMonitorUpdate_free(this_obj_conv);
27209 }
27210
27211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27212         LDKChannelMonitorUpdate this_ptr_conv;
27213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27214         this_ptr_conv.is_owned = false;
27215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27216         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
27217         return ret_conv;
27218 }
27219
27220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27221         LDKChannelMonitorUpdate this_ptr_conv;
27222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27223         this_ptr_conv.is_owned = false;
27224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27225         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
27226 }
27227
27228 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
27229         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
27230 int64_t ret_ref = 0;
27231 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27232 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27233 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27234 ret_ref = (uintptr_t)ret_var.inner;
27235 if (ret_var.is_owned) {
27236         ret_ref |= 1;
27237 }
27238         return ret_ref;
27239 }
27240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27241         LDKChannelMonitorUpdate arg_conv;
27242         arg_conv.inner = (void*)(arg & (~1));
27243         arg_conv.is_owned = false;
27244         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27245         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
27246         return ret_conv;
27247 }
27248
27249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27250         LDKChannelMonitorUpdate orig_conv;
27251         orig_conv.inner = (void*)(orig & (~1));
27252         orig_conv.is_owned = false;
27253         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27254         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
27255         int64_t ret_ref = 0;
27256         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27257         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27259         ret_ref = (uintptr_t)ret_var.inner;
27260         if (ret_var.is_owned) {
27261                 ret_ref |= 1;
27262         }
27263         return ret_ref;
27264 }
27265
27266 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
27267         LDKChannelMonitorUpdate obj_conv;
27268         obj_conv.inner = (void*)(obj & (~1));
27269         obj_conv.is_owned = false;
27270         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27271         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
27272         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27273         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27274         CVec_u8Z_free(ret_var);
27275         return ret_arr;
27276 }
27277
27278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27279         LDKu8slice ser_ref;
27280         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27281         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27282         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
27283         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
27284         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27285         return (int64_t)ret_conv;
27286 }
27287
27288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27289         if ((this_ptr & 1) != 0) return;
27290         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27291         CHECK_ACCESS(this_ptr_ptr);
27292         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
27293         FREE((void*)this_ptr);
27294         MonitorEvent_free(this_ptr_conv);
27295 }
27296
27297 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
27298         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27299         *ret_copy = MonitorEvent_clone(arg);
27300 int64_t ret_ref = (uintptr_t)ret_copy;
27301         return ret_ref;
27302 }
27303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27304         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
27305         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
27306         return ret_conv;
27307 }
27308
27309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27310         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
27311         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27312         *ret_copy = MonitorEvent_clone(orig_conv);
27313         int64_t ret_ref = (uintptr_t)ret_copy;
27314         return ret_ref;
27315 }
27316
27317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
27318         LDKHTLCUpdate a_conv;
27319         a_conv.inner = (void*)(a & (~1));
27320         a_conv.is_owned = (a & 1) || (a == 0);
27321         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27322         a_conv = HTLCUpdate_clone(&a_conv);
27323         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27324         *ret_copy = MonitorEvent_htlcevent(a_conv);
27325         int64_t ret_ref = (uintptr_t)ret_copy;
27326         return ret_ref;
27327 }
27328
27329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
27330         LDKOutPoint a_conv;
27331         a_conv.inner = (void*)(a & (~1));
27332         a_conv.is_owned = (a & 1) || (a == 0);
27333         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27334         a_conv = OutPoint_clone(&a_conv);
27335         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27336         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
27337         int64_t ret_ref = (uintptr_t)ret_copy;
27338         return ret_ref;
27339 }
27340
27341 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) {
27342         LDKOutPoint funding_txo_conv;
27343         funding_txo_conv.inner = (void*)(funding_txo & (~1));
27344         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
27345         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
27346         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
27347         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27348         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
27349         int64_t ret_ref = (uintptr_t)ret_copy;
27350         return ret_ref;
27351 }
27352
27353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
27354         LDKOutPoint a_conv;
27355         a_conv.inner = (void*)(a & (~1));
27356         a_conv.is_owned = (a & 1) || (a == 0);
27357         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27358         a_conv = OutPoint_clone(&a_conv);
27359         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27360         *ret_copy = MonitorEvent_update_failed(a_conv);
27361         int64_t ret_ref = (uintptr_t)ret_copy;
27362         return ret_ref;
27363 }
27364
27365 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
27366         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
27367         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
27368         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27369         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27370         CVec_u8Z_free(ret_var);
27371         return ret_arr;
27372 }
27373
27374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27375         LDKu8slice ser_ref;
27376         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27377         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27378         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
27379         *ret_conv = MonitorEvent_read(ser_ref);
27380         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27381         return (int64_t)ret_conv;
27382 }
27383
27384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27385         LDKHTLCUpdate this_obj_conv;
27386         this_obj_conv.inner = (void*)(this_obj & (~1));
27387         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27389         HTLCUpdate_free(this_obj_conv);
27390 }
27391
27392 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
27393         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
27394 int64_t ret_ref = 0;
27395 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27396 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27397 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27398 ret_ref = (uintptr_t)ret_var.inner;
27399 if (ret_var.is_owned) {
27400         ret_ref |= 1;
27401 }
27402         return ret_ref;
27403 }
27404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27405         LDKHTLCUpdate arg_conv;
27406         arg_conv.inner = (void*)(arg & (~1));
27407         arg_conv.is_owned = false;
27408         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27409         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
27410         return ret_conv;
27411 }
27412
27413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27414         LDKHTLCUpdate orig_conv;
27415         orig_conv.inner = (void*)(orig & (~1));
27416         orig_conv.is_owned = false;
27417         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27418         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
27419         int64_t ret_ref = 0;
27420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27423         ret_ref = (uintptr_t)ret_var.inner;
27424         if (ret_var.is_owned) {
27425                 ret_ref |= 1;
27426         }
27427         return ret_ref;
27428 }
27429
27430 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
27431         LDKHTLCUpdate obj_conv;
27432         obj_conv.inner = (void*)(obj & (~1));
27433         obj_conv.is_owned = false;
27434         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27435         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
27436         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27437         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27438         CVec_u8Z_free(ret_var);
27439         return ret_arr;
27440 }
27441
27442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27443         LDKu8slice ser_ref;
27444         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27445         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27446         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
27447         *ret_conv = HTLCUpdate_read(ser_ref);
27448         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27449         return (int64_t)ret_conv;
27450 }
27451
27452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27453         if ((this_ptr & 1) != 0) return;
27454         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27455         CHECK_ACCESS(this_ptr_ptr);
27456         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
27457         FREE((void*)this_ptr);
27458         Balance_free(this_ptr_conv);
27459 }
27460
27461 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
27462         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27463         *ret_copy = Balance_clone(arg);
27464 int64_t ret_ref = (uintptr_t)ret_copy;
27465         return ret_ref;
27466 }
27467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27468         LDKBalance* arg_conv = (LDKBalance*)arg;
27469         int64_t ret_conv = Balance_clone_ptr(arg_conv);
27470         return ret_conv;
27471 }
27472
27473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27474         LDKBalance* orig_conv = (LDKBalance*)orig;
27475         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27476         *ret_copy = Balance_clone(orig_conv);
27477         int64_t ret_ref = (uintptr_t)ret_copy;
27478         return ret_ref;
27479 }
27480
27481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
27482         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27483         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
27484         int64_t ret_ref = (uintptr_t)ret_copy;
27485         return ret_ref;
27486 }
27487
27488 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) {
27489         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27490         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
27491         int64_t ret_ref = (uintptr_t)ret_copy;
27492         return ret_ref;
27493 }
27494
27495 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) {
27496         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27497         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
27498         int64_t ret_ref = (uintptr_t)ret_copy;
27499         return ret_ref;
27500 }
27501
27502 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) {
27503         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27504         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
27505         int64_t ret_ref = (uintptr_t)ret_copy;
27506         return ret_ref;
27507 }
27508
27509 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27510         LDKBalance* a_conv = (LDKBalance*)a;
27511         LDKBalance* b_conv = (LDKBalance*)b;
27512         jboolean ret_conv = Balance_eq(a_conv, b_conv);
27513         return ret_conv;
27514 }
27515
27516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27517         LDKChannelMonitor this_obj_conv;
27518         this_obj_conv.inner = (void*)(this_obj & (~1));
27519         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27521         ChannelMonitor_free(this_obj_conv);
27522 }
27523
27524 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
27525         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
27526 int64_t ret_ref = 0;
27527 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27528 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27529 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27530 ret_ref = (uintptr_t)ret_var.inner;
27531 if (ret_var.is_owned) {
27532         ret_ref |= 1;
27533 }
27534         return ret_ref;
27535 }
27536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27537         LDKChannelMonitor arg_conv;
27538         arg_conv.inner = (void*)(arg & (~1));
27539         arg_conv.is_owned = false;
27540         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27541         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
27542         return ret_conv;
27543 }
27544
27545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27546         LDKChannelMonitor orig_conv;
27547         orig_conv.inner = (void*)(orig & (~1));
27548         orig_conv.is_owned = false;
27549         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27550         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
27551         int64_t ret_ref = 0;
27552         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27553         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27555         ret_ref = (uintptr_t)ret_var.inner;
27556         if (ret_var.is_owned) {
27557                 ret_ref |= 1;
27558         }
27559         return ret_ref;
27560 }
27561
27562 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27563         LDKChannelMonitor obj_conv;
27564         obj_conv.inner = (void*)(obj & (~1));
27565         obj_conv.is_owned = false;
27566         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27567         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
27568         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27569         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27570         CVec_u8Z_free(ret_var);
27571         return ret_arr;
27572 }
27573
27574 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) {
27575         LDKChannelMonitor this_arg_conv;
27576         this_arg_conv.inner = (void*)(this_arg & (~1));
27577         this_arg_conv.is_owned = false;
27578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27579         LDKChannelMonitorUpdate updates_conv;
27580         updates_conv.inner = (void*)(updates & (~1));
27581         updates_conv.is_owned = false;
27582         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
27583         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27584         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
27585         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
27586         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27587         CHECK_ACCESS(fee_estimator_ptr);
27588         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27589         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27590                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27591                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27592         }
27593         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27594         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
27595         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
27596         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
27597         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
27598         return (int64_t)ret_conv;
27599 }
27600
27601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
27602         LDKChannelMonitor this_arg_conv;
27603         this_arg_conv.inner = (void*)(this_arg & (~1));
27604         this_arg_conv.is_owned = false;
27605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27606         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
27607         return ret_conv;
27608 }
27609
27610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
27611         LDKChannelMonitor this_arg_conv;
27612         this_arg_conv.inner = (void*)(this_arg & (~1));
27613         this_arg_conv.is_owned = false;
27614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27615         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
27616         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
27617         return ((int64_t)ret_conv);
27618 }
27619
27620 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
27621         LDKChannelMonitor this_arg_conv;
27622         this_arg_conv.inner = (void*)(this_arg & (~1));
27623         this_arg_conv.is_owned = false;
27624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27625         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
27626         int64_tArray ret_arr = NULL;
27627         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27628         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27629         for (size_t o = 0; o < ret_var.datalen; o++) {
27630                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
27631                 *ret_conv_40_conv = ret_var.data[o];
27632                 ret_arr_ptr[o] = ((int64_t)ret_conv_40_conv);
27633         }
27634         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27635         FREE(ret_var.data);
27636         return ret_arr;
27637 }
27638
27639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
27640         LDKChannelMonitor this_arg_conv;
27641         this_arg_conv.inner = (void*)(this_arg & (~1));
27642         this_arg_conv.is_owned = false;
27643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27644         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
27645         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
27646         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
27647         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
27648 }
27649
27650 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
27651         LDKChannelMonitor this_arg_conv;
27652         this_arg_conv.inner = (void*)(this_arg & (~1));
27653         this_arg_conv.is_owned = false;
27654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27655         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
27656         int64_tArray ret_arr = NULL;
27657         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27658         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27659         for (size_t o = 0; o < ret_var.datalen; o++) {
27660                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27661                 *ret_conv_14_copy = ret_var.data[o];
27662                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
27663                 ret_arr_ptr[o] = ret_conv_14_ref;
27664         }
27665         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27666         FREE(ret_var.data);
27667         return ret_arr;
27668 }
27669
27670 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
27671         LDKChannelMonitor this_arg_conv;
27672         this_arg_conv.inner = (void*)(this_arg & (~1));
27673         this_arg_conv.is_owned = false;
27674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27675         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
27676         int64_tArray ret_arr = NULL;
27677         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27678         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27679         for (size_t h = 0; h < ret_var.datalen; h++) {
27680                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
27681                 *ret_conv_7_copy = ret_var.data[h];
27682                 int64_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
27683                 ret_arr_ptr[h] = ret_conv_7_ref;
27684         }
27685         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27686         FREE(ret_var.data);
27687         return ret_arr;
27688 }
27689
27690 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1counterparty_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
27691         LDKChannelMonitor this_arg_conv;
27692         this_arg_conv.inner = (void*)(this_arg & (~1));
27693         this_arg_conv.is_owned = false;
27694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27695         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27696         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form);
27697         return ret_arr;
27698 }
27699
27700 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) {
27701         LDKChannelMonitor this_arg_conv;
27702         this_arg_conv.inner = (void*)(this_arg & (~1));
27703         this_arg_conv.is_owned = false;
27704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27705         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27706         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
27707         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
27708         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
27709         jobjectArray ret_arr = NULL;
27710         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
27711         ;
27712         for (size_t i = 0; i < ret_var.datalen; i++) {
27713                 LDKTransaction ret_conv_8_var = ret_var.data[i];
27714                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
27715                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
27716                 Transaction_free(ret_conv_8_var);
27717                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
27718         }
27719         
27720         FREE(ret_var.data);
27721         return ret_arr;
27722 }
27723
27724 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) {
27725         LDKChannelMonitor this_arg_conv;
27726         this_arg_conv.inner = (void*)(this_arg & (~1));
27727         this_arg_conv.is_owned = false;
27728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27729         unsigned char header_arr[80];
27730         CHECK((*env)->GetArrayLength(env, header) == 80);
27731         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27732         unsigned char (*header_ref)[80] = &header_arr;
27733         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
27734         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
27735         if (txdata_constr.datalen > 0)
27736                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
27737         else
27738                 txdata_constr.data = NULL;
27739         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
27740         for (size_t c = 0; c < txdata_constr.datalen; c++) {
27741                 int64_t txdata_conv_28 = txdata_vals[c];
27742                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
27743                 CHECK_ACCESS(txdata_conv_28_ptr);
27744                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
27745                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
27746                 txdata_constr.data[c] = txdata_conv_28_conv;
27747         }
27748         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
27749         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27750         CHECK_ACCESS(broadcaster_ptr);
27751         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27752         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27753                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27754                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27755         }
27756         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27757         CHECK_ACCESS(fee_estimator_ptr);
27758         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27759         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27760                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27761                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27762         }
27763         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27764         CHECK_ACCESS(logger_ptr);
27765         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27766         if (logger_conv.free == LDKLogger_JCalls_free) {
27767                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27768                 LDKLogger_JCalls_cloned(&logger_conv);
27769         }
27770         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);
27771         int64_tArray ret_arr = NULL;
27772         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27773         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27774         for (size_t n = 0; n < ret_var.datalen; n++) {
27775                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
27776                 *ret_conv_39_conv = ret_var.data[n];
27777                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
27778         }
27779         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27780         FREE(ret_var.data);
27781         return ret_arr;
27782 }
27783
27784 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) {
27785         LDKChannelMonitor this_arg_conv;
27786         this_arg_conv.inner = (void*)(this_arg & (~1));
27787         this_arg_conv.is_owned = false;
27788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27789         unsigned char header_arr[80];
27790         CHECK((*env)->GetArrayLength(env, header) == 80);
27791         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27792         unsigned char (*header_ref)[80] = &header_arr;
27793         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27794         CHECK_ACCESS(broadcaster_ptr);
27795         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27796         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27797                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27798                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27799         }
27800         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27801         CHECK_ACCESS(fee_estimator_ptr);
27802         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27803         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27804                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27805                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27806         }
27807         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27808         CHECK_ACCESS(logger_ptr);
27809         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27810         if (logger_conv.free == LDKLogger_JCalls_free) {
27811                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27812                 LDKLogger_JCalls_cloned(&logger_conv);
27813         }
27814         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
27815 }
27816
27817 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) {
27818         LDKChannelMonitor this_arg_conv;
27819         this_arg_conv.inner = (void*)(this_arg & (~1));
27820         this_arg_conv.is_owned = false;
27821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27822         unsigned char header_arr[80];
27823         CHECK((*env)->GetArrayLength(env, header) == 80);
27824         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27825         unsigned char (*header_ref)[80] = &header_arr;
27826         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
27827         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
27828         if (txdata_constr.datalen > 0)
27829                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
27830         else
27831                 txdata_constr.data = NULL;
27832         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
27833         for (size_t c = 0; c < txdata_constr.datalen; c++) {
27834                 int64_t txdata_conv_28 = txdata_vals[c];
27835                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
27836                 CHECK_ACCESS(txdata_conv_28_ptr);
27837                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
27838                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
27839                 txdata_constr.data[c] = txdata_conv_28_conv;
27840         }
27841         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
27842         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27843         CHECK_ACCESS(broadcaster_ptr);
27844         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27845         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27846                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27847                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27848         }
27849         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27850         CHECK_ACCESS(fee_estimator_ptr);
27851         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27852         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27853                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27854                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27855         }
27856         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27857         CHECK_ACCESS(logger_ptr);
27858         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27859         if (logger_conv.free == LDKLogger_JCalls_free) {
27860                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27861                 LDKLogger_JCalls_cloned(&logger_conv);
27862         }
27863         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);
27864         int64_tArray ret_arr = NULL;
27865         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27866         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27867         for (size_t n = 0; n < ret_var.datalen; n++) {
27868                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
27869                 *ret_conv_39_conv = ret_var.data[n];
27870                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
27871         }
27872         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27873         FREE(ret_var.data);
27874         return ret_arr;
27875 }
27876
27877 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) {
27878         LDKChannelMonitor this_arg_conv;
27879         this_arg_conv.inner = (void*)(this_arg & (~1));
27880         this_arg_conv.is_owned = false;
27881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27882         unsigned char txid_arr[32];
27883         CHECK((*env)->GetArrayLength(env, txid) == 32);
27884         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
27885         unsigned char (*txid_ref)[32] = &txid_arr;
27886         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27887         CHECK_ACCESS(broadcaster_ptr);
27888         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27889         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27890                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27891                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27892         }
27893         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27894         CHECK_ACCESS(fee_estimator_ptr);
27895         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27896         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27897                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27898                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27899         }
27900         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27901         CHECK_ACCESS(logger_ptr);
27902         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27903         if (logger_conv.free == LDKLogger_JCalls_free) {
27904                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27905                 LDKLogger_JCalls_cloned(&logger_conv);
27906         }
27907         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
27908 }
27909
27910 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) {
27911         LDKChannelMonitor this_arg_conv;
27912         this_arg_conv.inner = (void*)(this_arg & (~1));
27913         this_arg_conv.is_owned = false;
27914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27915         unsigned char header_arr[80];
27916         CHECK((*env)->GetArrayLength(env, header) == 80);
27917         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27918         unsigned char (*header_ref)[80] = &header_arr;
27919         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27920         CHECK_ACCESS(broadcaster_ptr);
27921         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27922         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27923                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27924                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27925         }
27926         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27927         CHECK_ACCESS(fee_estimator_ptr);
27928         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27929         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27930                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27931                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27932         }
27933         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27934         CHECK_ACCESS(logger_ptr);
27935         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27936         if (logger_conv.free == LDKLogger_JCalls_free) {
27937                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27938                 LDKLogger_JCalls_cloned(&logger_conv);
27939         }
27940         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
27941         int64_tArray ret_arr = NULL;
27942         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27943         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27944         for (size_t n = 0; n < ret_var.datalen; n++) {
27945                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
27946                 *ret_conv_39_conv = ret_var.data[n];
27947                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
27948         }
27949         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27950         FREE(ret_var.data);
27951         return ret_arr;
27952 }
27953
27954 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
27955         LDKChannelMonitor this_arg_conv;
27956         this_arg_conv.inner = (void*)(this_arg & (~1));
27957         this_arg_conv.is_owned = false;
27958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27959         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
27960         jobjectArray ret_arr = NULL;
27961         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
27962         ;
27963         for (size_t i = 0; i < ret_var.datalen; i++) {
27964                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
27965                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
27966                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
27967         }
27968         
27969         FREE(ret_var.data);
27970         return ret_arr;
27971 }
27972
27973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
27974         LDKChannelMonitor this_arg_conv;
27975         this_arg_conv.inner = (void*)(this_arg & (~1));
27976         this_arg_conv.is_owned = false;
27977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27978         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
27979         int64_t ret_ref = 0;
27980         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27981         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27983         ret_ref = (uintptr_t)ret_var.inner;
27984         if (ret_var.is_owned) {
27985                 ret_ref |= 1;
27986         }
27987         return ret_ref;
27988 }
27989
27990 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
27991         LDKChannelMonitor this_arg_conv;
27992         this_arg_conv.inner = (void*)(this_arg & (~1));
27993         this_arg_conv.is_owned = false;
27994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27995         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
27996         int64_tArray ret_arr = NULL;
27997         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27998         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27999         for (size_t j = 0; j < ret_var.datalen; j++) {
28000                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28001                 *ret_conv_9_copy = ret_var.data[j];
28002                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
28003                 ret_arr_ptr[j] = ret_conv_9_ref;
28004         }
28005         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28006         FREE(ret_var.data);
28007         return ret_arr;
28008 }
28009
28010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
28011         LDKu8slice ser_ref;
28012         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28013         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28014         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
28015         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
28016         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
28017         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
28018         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
28019         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28020         return (int64_t)ret_conv;
28021 }
28022
28023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28024         LDKOutPoint this_obj_conv;
28025         this_obj_conv.inner = (void*)(this_obj & (~1));
28026         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28028         OutPoint_free(this_obj_conv);
28029 }
28030
28031 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
28032         LDKOutPoint this_ptr_conv;
28033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28034         this_ptr_conv.is_owned = false;
28035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28036         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28037         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
28038         return ret_arr;
28039 }
28040
28041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28042         LDKOutPoint this_ptr_conv;
28043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28044         this_ptr_conv.is_owned = false;
28045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28046         LDKThirtyTwoBytes val_ref;
28047         CHECK((*env)->GetArrayLength(env, val) == 32);
28048         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28049         OutPoint_set_txid(&this_ptr_conv, val_ref);
28050 }
28051
28052 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
28053         LDKOutPoint this_ptr_conv;
28054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28055         this_ptr_conv.is_owned = false;
28056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28057         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
28058         return ret_conv;
28059 }
28060
28061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28062         LDKOutPoint this_ptr_conv;
28063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28064         this_ptr_conv.is_owned = false;
28065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28066         OutPoint_set_index(&this_ptr_conv, val);
28067 }
28068
28069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
28070         LDKThirtyTwoBytes txid_arg_ref;
28071         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
28072         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
28073         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
28074         int64_t ret_ref = 0;
28075         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28076         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28078         ret_ref = (uintptr_t)ret_var.inner;
28079         if (ret_var.is_owned) {
28080                 ret_ref |= 1;
28081         }
28082         return ret_ref;
28083 }
28084
28085 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
28086         LDKOutPoint ret_var = OutPoint_clone(arg);
28087 int64_t ret_ref = 0;
28088 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28089 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28090 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28091 ret_ref = (uintptr_t)ret_var.inner;
28092 if (ret_var.is_owned) {
28093         ret_ref |= 1;
28094 }
28095         return ret_ref;
28096 }
28097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28098         LDKOutPoint arg_conv;
28099         arg_conv.inner = (void*)(arg & (~1));
28100         arg_conv.is_owned = false;
28101         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28102         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
28103         return ret_conv;
28104 }
28105
28106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28107         LDKOutPoint orig_conv;
28108         orig_conv.inner = (void*)(orig & (~1));
28109         orig_conv.is_owned = false;
28110         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28111         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
28112         int64_t ret_ref = 0;
28113         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28114         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28116         ret_ref = (uintptr_t)ret_var.inner;
28117         if (ret_var.is_owned) {
28118                 ret_ref |= 1;
28119         }
28120         return ret_ref;
28121 }
28122
28123 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28124         LDKOutPoint a_conv;
28125         a_conv.inner = (void*)(a & (~1));
28126         a_conv.is_owned = false;
28127         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28128         LDKOutPoint b_conv;
28129         b_conv.inner = (void*)(b & (~1));
28130         b_conv.is_owned = false;
28131         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28132         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
28133         return ret_conv;
28134 }
28135
28136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
28137         LDKOutPoint o_conv;
28138         o_conv.inner = (void*)(o & (~1));
28139         o_conv.is_owned = false;
28140         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28141         int64_t ret_conv = OutPoint_hash(&o_conv);
28142         return ret_conv;
28143 }
28144
28145 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
28146         LDKOutPoint this_arg_conv;
28147         this_arg_conv.inner = (void*)(this_arg & (~1));
28148         this_arg_conv.is_owned = false;
28149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28150         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28151         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
28152         return ret_arr;
28153 }
28154
28155 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
28156         LDKOutPoint obj_conv;
28157         obj_conv.inner = (void*)(obj & (~1));
28158         obj_conv.is_owned = false;
28159         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28160         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
28161         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28162         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28163         CVec_u8Z_free(ret_var);
28164         return ret_arr;
28165 }
28166
28167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28168         LDKu8slice ser_ref;
28169         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28170         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28171         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
28172         *ret_conv = OutPoint_read(ser_ref);
28173         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28174         return (int64_t)ret_conv;
28175 }
28176
28177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28178         LDKDelayedPaymentOutputDescriptor this_obj_conv;
28179         this_obj_conv.inner = (void*)(this_obj & (~1));
28180         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28182         DelayedPaymentOutputDescriptor_free(this_obj_conv);
28183 }
28184
28185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28186         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28188         this_ptr_conv.is_owned = false;
28189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28190         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
28191         int64_t ret_ref = 0;
28192         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28193         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28194         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28195         ret_ref = (uintptr_t)ret_var.inner;
28196         if (ret_var.is_owned) {
28197                 ret_ref |= 1;
28198         }
28199         return ret_ref;
28200 }
28201
28202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28203         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28205         this_ptr_conv.is_owned = false;
28206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28207         LDKOutPoint val_conv;
28208         val_conv.inner = (void*)(val & (~1));
28209         val_conv.is_owned = (val & 1) || (val == 0);
28210         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28211         val_conv = OutPoint_clone(&val_conv);
28212         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
28213 }
28214
28215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
28216         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28218         this_ptr_conv.is_owned = false;
28219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28220         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28221         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
28222         return ret_arr;
28223 }
28224
28225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28226         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28228         this_ptr_conv.is_owned = false;
28229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28230         LDKPublicKey val_ref;
28231         CHECK((*env)->GetArrayLength(env, val) == 33);
28232         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28233         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
28234 }
28235
28236 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
28237         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28239         this_ptr_conv.is_owned = false;
28240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28241         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
28242         return ret_conv;
28243 }
28244
28245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28246         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28248         this_ptr_conv.is_owned = false;
28249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28250         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
28251 }
28252
28253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
28254         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28256         this_ptr_conv.is_owned = false;
28257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28258         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
28259         *ret_ref = DelayedPaymentOutputDescriptor_get_output(&this_ptr_conv);
28260         return (int64_t)ret_ref;
28261 }
28262
28263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28264         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28266         this_ptr_conv.is_owned = false;
28267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28268         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28269         CHECK_ACCESS(val_ptr);
28270         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
28271         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
28272         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
28273 }
28274
28275 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28276         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28278         this_ptr_conv.is_owned = false;
28279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28280         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28281         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
28282         return ret_arr;
28283 }
28284
28285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28286         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28288         this_ptr_conv.is_owned = false;
28289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28290         LDKPublicKey val_ref;
28291         CHECK((*env)->GetArrayLength(env, val) == 33);
28292         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28293         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
28294 }
28295
28296 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28297         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28299         this_ptr_conv.is_owned = false;
28300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28301         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28302         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
28303         return ret_arr;
28304 }
28305
28306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28307         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28309         this_ptr_conv.is_owned = false;
28310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28311         LDKThirtyTwoBytes val_ref;
28312         CHECK((*env)->GetArrayLength(env, val) == 32);
28313         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28314         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
28315 }
28316
28317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28318         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28320         this_ptr_conv.is_owned = false;
28321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28322         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
28323         return ret_conv;
28324 }
28325
28326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28327         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28329         this_ptr_conv.is_owned = false;
28330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28331         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
28332 }
28333
28334 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) {
28335         LDKOutPoint outpoint_arg_conv;
28336         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
28337         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
28338         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
28339         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
28340         LDKPublicKey per_commitment_point_arg_ref;
28341         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
28342         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
28343         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
28344         CHECK_ACCESS(output_arg_ptr);
28345         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
28346         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
28347         LDKPublicKey revocation_pubkey_arg_ref;
28348         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
28349         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
28350         LDKThirtyTwoBytes channel_keys_id_arg_ref;
28351         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
28352         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
28353         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);
28354         int64_t ret_ref = 0;
28355         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28356         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28358         ret_ref = (uintptr_t)ret_var.inner;
28359         if (ret_var.is_owned) {
28360                 ret_ref |= 1;
28361         }
28362         return ret_ref;
28363 }
28364
28365 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
28366         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
28367 int64_t ret_ref = 0;
28368 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28369 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28370 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28371 ret_ref = (uintptr_t)ret_var.inner;
28372 if (ret_var.is_owned) {
28373         ret_ref |= 1;
28374 }
28375         return ret_ref;
28376 }
28377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28378         LDKDelayedPaymentOutputDescriptor arg_conv;
28379         arg_conv.inner = (void*)(arg & (~1));
28380         arg_conv.is_owned = false;
28381         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28382         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
28383         return ret_conv;
28384 }
28385
28386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28387         LDKDelayedPaymentOutputDescriptor orig_conv;
28388         orig_conv.inner = (void*)(orig & (~1));
28389         orig_conv.is_owned = false;
28390         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28391         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
28392         int64_t ret_ref = 0;
28393         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28394         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28396         ret_ref = (uintptr_t)ret_var.inner;
28397         if (ret_var.is_owned) {
28398                 ret_ref |= 1;
28399         }
28400         return ret_ref;
28401 }
28402
28403 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
28404         LDKDelayedPaymentOutputDescriptor obj_conv;
28405         obj_conv.inner = (void*)(obj & (~1));
28406         obj_conv.is_owned = false;
28407         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28408         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
28409         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28410         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28411         CVec_u8Z_free(ret_var);
28412         return ret_arr;
28413 }
28414
28415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28416         LDKu8slice ser_ref;
28417         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28418         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28419         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
28420         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
28421         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28422         return (int64_t)ret_conv;
28423 }
28424
28425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28426         LDKStaticPaymentOutputDescriptor this_obj_conv;
28427         this_obj_conv.inner = (void*)(this_obj & (~1));
28428         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28430         StaticPaymentOutputDescriptor_free(this_obj_conv);
28431 }
28432
28433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28434         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28436         this_ptr_conv.is_owned = false;
28437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28438         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
28439         int64_t ret_ref = 0;
28440         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28441         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28443         ret_ref = (uintptr_t)ret_var.inner;
28444         if (ret_var.is_owned) {
28445                 ret_ref |= 1;
28446         }
28447         return ret_ref;
28448 }
28449
28450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28451         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28453         this_ptr_conv.is_owned = false;
28454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28455         LDKOutPoint val_conv;
28456         val_conv.inner = (void*)(val & (~1));
28457         val_conv.is_owned = (val & 1) || (val == 0);
28458         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28459         val_conv = OutPoint_clone(&val_conv);
28460         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
28461 }
28462
28463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
28464         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28466         this_ptr_conv.is_owned = false;
28467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28468         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
28469         *ret_ref = StaticPaymentOutputDescriptor_get_output(&this_ptr_conv);
28470         return (int64_t)ret_ref;
28471 }
28472
28473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28474         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28476         this_ptr_conv.is_owned = false;
28477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28478         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28479         CHECK_ACCESS(val_ptr);
28480         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
28481         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
28482         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
28483 }
28484
28485 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28486         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28488         this_ptr_conv.is_owned = false;
28489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28490         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28491         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
28492         return ret_arr;
28493 }
28494
28495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28496         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28498         this_ptr_conv.is_owned = false;
28499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28500         LDKThirtyTwoBytes val_ref;
28501         CHECK((*env)->GetArrayLength(env, val) == 32);
28502         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28503         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
28504 }
28505
28506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28507         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28509         this_ptr_conv.is_owned = false;
28510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28511         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
28512         return ret_conv;
28513 }
28514
28515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28516         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28518         this_ptr_conv.is_owned = false;
28519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28520         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
28521 }
28522
28523 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) {
28524         LDKOutPoint outpoint_arg_conv;
28525         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
28526         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
28527         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
28528         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
28529         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
28530         CHECK_ACCESS(output_arg_ptr);
28531         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
28532         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
28533         LDKThirtyTwoBytes channel_keys_id_arg_ref;
28534         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
28535         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
28536         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
28537         int64_t ret_ref = 0;
28538         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28539         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28541         ret_ref = (uintptr_t)ret_var.inner;
28542         if (ret_var.is_owned) {
28543                 ret_ref |= 1;
28544         }
28545         return ret_ref;
28546 }
28547
28548 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
28549         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
28550 int64_t ret_ref = 0;
28551 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28552 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28553 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28554 ret_ref = (uintptr_t)ret_var.inner;
28555 if (ret_var.is_owned) {
28556         ret_ref |= 1;
28557 }
28558         return ret_ref;
28559 }
28560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28561         LDKStaticPaymentOutputDescriptor arg_conv;
28562         arg_conv.inner = (void*)(arg & (~1));
28563         arg_conv.is_owned = false;
28564         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28565         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
28566         return ret_conv;
28567 }
28568
28569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28570         LDKStaticPaymentOutputDescriptor orig_conv;
28571         orig_conv.inner = (void*)(orig & (~1));
28572         orig_conv.is_owned = false;
28573         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28574         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
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 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
28587         LDKStaticPaymentOutputDescriptor obj_conv;
28588         obj_conv.inner = (void*)(obj & (~1));
28589         obj_conv.is_owned = false;
28590         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28591         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
28592         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28593         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28594         CVec_u8Z_free(ret_var);
28595         return ret_arr;
28596 }
28597
28598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28599         LDKu8slice ser_ref;
28600         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28601         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28602         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
28603         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
28604         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28605         return (int64_t)ret_conv;
28606 }
28607
28608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28609         if ((this_ptr & 1) != 0) return;
28610         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28611         CHECK_ACCESS(this_ptr_ptr);
28612         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
28613         FREE((void*)this_ptr);
28614         SpendableOutputDescriptor_free(this_ptr_conv);
28615 }
28616
28617 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
28618         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28619         *ret_copy = SpendableOutputDescriptor_clone(arg);
28620 int64_t ret_ref = (uintptr_t)ret_copy;
28621         return ret_ref;
28622 }
28623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28624         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
28625         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
28626         return ret_conv;
28627 }
28628
28629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28630         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
28631         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28632         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
28633         int64_t ret_ref = (uintptr_t)ret_copy;
28634         return ret_ref;
28635 }
28636
28637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
28638         LDKOutPoint outpoint_conv;
28639         outpoint_conv.inner = (void*)(outpoint & (~1));
28640         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
28641         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
28642         outpoint_conv = OutPoint_clone(&outpoint_conv);
28643         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
28644         CHECK_ACCESS(output_ptr);
28645         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
28646         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
28647         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28648         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
28649         int64_t ret_ref = (uintptr_t)ret_copy;
28650         return ret_ref;
28651 }
28652
28653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
28654         LDKDelayedPaymentOutputDescriptor a_conv;
28655         a_conv.inner = (void*)(a & (~1));
28656         a_conv.is_owned = (a & 1) || (a == 0);
28657         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28658         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
28659         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28660         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
28661         int64_t ret_ref = (uintptr_t)ret_copy;
28662         return ret_ref;
28663 }
28664
28665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
28666         LDKStaticPaymentOutputDescriptor a_conv;
28667         a_conv.inner = (void*)(a & (~1));
28668         a_conv.is_owned = (a & 1) || (a == 0);
28669         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28670         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
28671         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28672         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
28673         int64_t ret_ref = (uintptr_t)ret_copy;
28674         return ret_ref;
28675 }
28676
28677 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
28678         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
28679         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
28680         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28681         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28682         CVec_u8Z_free(ret_var);
28683         return ret_arr;
28684 }
28685
28686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28687         LDKu8slice ser_ref;
28688         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28689         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28690         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
28691         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
28692         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28693         return (int64_t)ret_conv;
28694 }
28695
28696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28697         if ((this_ptr & 1) != 0) return;
28698         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28699         CHECK_ACCESS(this_ptr_ptr);
28700         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
28701         FREE((void*)this_ptr);
28702         BaseSign_free(this_ptr_conv);
28703 }
28704
28705 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
28706         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
28707         *ret_ret = Sign_clone(arg);
28708         return (int64_t)ret_ret;
28709 }
28710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28711         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
28712         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
28713         LDKSign* arg_conv = (LDKSign*)arg_ptr;
28714         int64_t ret_conv = Sign_clone_ptr(arg_conv);
28715         return ret_conv;
28716 }
28717
28718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28719         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
28720         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
28721         LDKSign* orig_conv = (LDKSign*)orig_ptr;
28722         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
28723         *ret_ret = Sign_clone(orig_conv);
28724         return (int64_t)ret_ret;
28725 }
28726
28727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28728         if ((this_ptr & 1) != 0) return;
28729         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28730         CHECK_ACCESS(this_ptr_ptr);
28731         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
28732         FREE((void*)this_ptr);
28733         Sign_free(this_ptr_conv);
28734 }
28735
28736 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28737         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
28738         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
28739         return ret_conv;
28740 }
28741
28742 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
28743         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
28744         return ret_conv;
28745 }
28746
28747 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
28748         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
28749         return ret_conv;
28750 }
28751
28752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28753         if ((this_ptr & 1) != 0) return;
28754         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28755         CHECK_ACCESS(this_ptr_ptr);
28756         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
28757         FREE((void*)this_ptr);
28758         KeysInterface_free(this_ptr_conv);
28759 }
28760
28761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28762         LDKInMemorySigner this_obj_conv;
28763         this_obj_conv.inner = (void*)(this_obj & (~1));
28764         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28766         InMemorySigner_free(this_obj_conv);
28767 }
28768
28769 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28770         LDKInMemorySigner this_ptr_conv;
28771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28772         this_ptr_conv.is_owned = false;
28773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28774         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28775         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
28776         return ret_arr;
28777 }
28778
28779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28780         LDKInMemorySigner this_ptr_conv;
28781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28782         this_ptr_conv.is_owned = false;
28783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28784         LDKSecretKey val_ref;
28785         CHECK((*env)->GetArrayLength(env, val) == 32);
28786         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28787         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
28788 }
28789
28790 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28791         LDKInMemorySigner this_ptr_conv;
28792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28793         this_ptr_conv.is_owned = false;
28794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28795         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28796         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
28797         return ret_arr;
28798 }
28799
28800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28801         LDKInMemorySigner this_ptr_conv;
28802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28803         this_ptr_conv.is_owned = false;
28804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28805         LDKSecretKey val_ref;
28806         CHECK((*env)->GetArrayLength(env, val) == 32);
28807         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28808         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
28809 }
28810
28811 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28812         LDKInMemorySigner this_ptr_conv;
28813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28814         this_ptr_conv.is_owned = false;
28815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28816         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28817         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
28818         return ret_arr;
28819 }
28820
28821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28822         LDKInMemorySigner this_ptr_conv;
28823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28824         this_ptr_conv.is_owned = false;
28825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28826         LDKSecretKey val_ref;
28827         CHECK((*env)->GetArrayLength(env, val) == 32);
28828         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28829         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
28830 }
28831
28832 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28833         LDKInMemorySigner this_ptr_conv;
28834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28835         this_ptr_conv.is_owned = false;
28836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28837         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28838         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
28839         return ret_arr;
28840 }
28841
28842 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) {
28843         LDKInMemorySigner this_ptr_conv;
28844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28845         this_ptr_conv.is_owned = false;
28846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28847         LDKSecretKey val_ref;
28848         CHECK((*env)->GetArrayLength(env, val) == 32);
28849         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28850         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
28851 }
28852
28853 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28854         LDKInMemorySigner this_ptr_conv;
28855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28856         this_ptr_conv.is_owned = false;
28857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28858         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28859         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
28860         return ret_arr;
28861 }
28862
28863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28864         LDKInMemorySigner this_ptr_conv;
28865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28866         this_ptr_conv.is_owned = false;
28867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28868         LDKSecretKey val_ref;
28869         CHECK((*env)->GetArrayLength(env, val) == 32);
28870         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28871         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
28872 }
28873
28874 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
28875         LDKInMemorySigner this_ptr_conv;
28876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28877         this_ptr_conv.is_owned = false;
28878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28879         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28880         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
28881         return ret_arr;
28882 }
28883
28884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28885         LDKInMemorySigner this_ptr_conv;
28886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28887         this_ptr_conv.is_owned = false;
28888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28889         LDKThirtyTwoBytes val_ref;
28890         CHECK((*env)->GetArrayLength(env, val) == 32);
28891         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28892         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
28893 }
28894
28895 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
28896         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
28897 int64_t ret_ref = 0;
28898 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28899 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28900 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28901 ret_ref = (uintptr_t)ret_var.inner;
28902 if (ret_var.is_owned) {
28903         ret_ref |= 1;
28904 }
28905         return ret_ref;
28906 }
28907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28908         LDKInMemorySigner arg_conv;
28909         arg_conv.inner = (void*)(arg & (~1));
28910         arg_conv.is_owned = false;
28911         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28912         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
28913         return ret_conv;
28914 }
28915
28916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28917         LDKInMemorySigner orig_conv;
28918         orig_conv.inner = (void*)(orig & (~1));
28919         orig_conv.is_owned = false;
28920         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28921         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
28922         int64_t ret_ref = 0;
28923         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28924         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28926         ret_ref = (uintptr_t)ret_var.inner;
28927         if (ret_var.is_owned) {
28928                 ret_ref |= 1;
28929         }
28930         return ret_ref;
28931 }
28932
28933 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) {
28934         LDKSecretKey node_secret_ref;
28935         CHECK((*env)->GetArrayLength(env, node_secret) == 32);
28936         (*env)->GetByteArrayRegion(env, node_secret, 0, 32, node_secret_ref.bytes);
28937         LDKSecretKey funding_key_ref;
28938         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
28939         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
28940         LDKSecretKey revocation_base_key_ref;
28941         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
28942         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
28943         LDKSecretKey payment_key_ref;
28944         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
28945         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
28946         LDKSecretKey delayed_payment_base_key_ref;
28947         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
28948         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
28949         LDKSecretKey htlc_base_key_ref;
28950         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
28951         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
28952         LDKThirtyTwoBytes commitment_seed_ref;
28953         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
28954         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
28955         LDKThirtyTwoBytes channel_keys_id_ref;
28956         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
28957         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
28958         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);
28959         int64_t ret_ref = 0;
28960         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28961         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28963         ret_ref = (uintptr_t)ret_var.inner;
28964         if (ret_var.is_owned) {
28965                 ret_ref |= 1;
28966         }
28967         return ret_ref;
28968 }
28969
28970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
28971         LDKInMemorySigner this_arg_conv;
28972         this_arg_conv.inner = (void*)(this_arg & (~1));
28973         this_arg_conv.is_owned = false;
28974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28975         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
28976         int64_t ret_ref = 0;
28977         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28978         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28980         ret_ref = (uintptr_t)ret_var.inner;
28981         if (ret_var.is_owned) {
28982                 ret_ref |= 1;
28983         }
28984         return ret_ref;
28985 }
28986
28987 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
28988         LDKInMemorySigner this_arg_conv;
28989         this_arg_conv.inner = (void*)(this_arg & (~1));
28990         this_arg_conv.is_owned = false;
28991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28992         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
28993         return ret_conv;
28994 }
28995
28996 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
28997         LDKInMemorySigner this_arg_conv;
28998         this_arg_conv.inner = (void*)(this_arg & (~1));
28999         this_arg_conv.is_owned = false;
29000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29001         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
29002         return ret_conv;
29003 }
29004
29005 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
29006         LDKInMemorySigner this_arg_conv;
29007         this_arg_conv.inner = (void*)(this_arg & (~1));
29008         this_arg_conv.is_owned = false;
29009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29010         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
29011         return ret_conv;
29012 }
29013
29014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
29015         LDKInMemorySigner this_arg_conv;
29016         this_arg_conv.inner = (void*)(this_arg & (~1));
29017         this_arg_conv.is_owned = false;
29018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29019         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
29020         int64_t ret_ref = 0;
29021         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29022         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29024         ret_ref = (uintptr_t)ret_var.inner;
29025         if (ret_var.is_owned) {
29026                 ret_ref |= 1;
29027         }
29028         return ret_ref;
29029 }
29030
29031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
29032         LDKInMemorySigner this_arg_conv;
29033         this_arg_conv.inner = (void*)(this_arg & (~1));
29034         this_arg_conv.is_owned = false;
29035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29036         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
29037         int64_t ret_ref = 0;
29038         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29039         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29041         ret_ref = (uintptr_t)ret_var.inner;
29042         if (ret_var.is_owned) {
29043                 ret_ref |= 1;
29044         }
29045         return ret_ref;
29046 }
29047
29048 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
29049         LDKInMemorySigner this_arg_conv;
29050         this_arg_conv.inner = (void*)(this_arg & (~1));
29051         this_arg_conv.is_owned = false;
29052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29053         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
29054         return ret_conv;
29055 }
29056
29057 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) {
29058         LDKInMemorySigner this_arg_conv;
29059         this_arg_conv.inner = (void*)(this_arg & (~1));
29060         this_arg_conv.is_owned = false;
29061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29062         LDKTransaction spend_tx_ref;
29063         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
29064         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
29065         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
29066         spend_tx_ref.data_is_owned = true;
29067         LDKStaticPaymentOutputDescriptor descriptor_conv;
29068         descriptor_conv.inner = (void*)(descriptor & (~1));
29069         descriptor_conv.is_owned = false;
29070         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
29071         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
29072         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
29073         return (int64_t)ret_conv;
29074 }
29075
29076 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) {
29077         LDKInMemorySigner this_arg_conv;
29078         this_arg_conv.inner = (void*)(this_arg & (~1));
29079         this_arg_conv.is_owned = false;
29080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29081         LDKTransaction spend_tx_ref;
29082         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
29083         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
29084         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
29085         spend_tx_ref.data_is_owned = true;
29086         LDKDelayedPaymentOutputDescriptor descriptor_conv;
29087         descriptor_conv.inner = (void*)(descriptor & (~1));
29088         descriptor_conv.is_owned = false;
29089         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
29090         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
29091         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
29092         return (int64_t)ret_conv;
29093 }
29094
29095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
29096         LDKInMemorySigner this_arg_conv;
29097         this_arg_conv.inner = (void*)(this_arg & (~1));
29098         this_arg_conv.is_owned = false;
29099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29100         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
29101         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
29102         return (int64_t)ret_ret;
29103 }
29104
29105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
29106         LDKInMemorySigner this_arg_conv;
29107         this_arg_conv.inner = (void*)(this_arg & (~1));
29108         this_arg_conv.is_owned = false;
29109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29110         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
29111         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
29112         return (int64_t)ret_ret;
29113 }
29114
29115 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
29116         LDKInMemorySigner obj_conv;
29117         obj_conv.inner = (void*)(obj & (~1));
29118         obj_conv.is_owned = false;
29119         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29120         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
29121         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29122         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29123         CVec_u8Z_free(ret_var);
29124         return ret_arr;
29125 }
29126
29127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int8_tArray arg) {
29128         LDKu8slice ser_ref;
29129         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29130         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29131         LDKSecretKey arg_ref;
29132         CHECK((*env)->GetArrayLength(env, arg) == 32);
29133         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
29134         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
29135         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
29136         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29137         return (int64_t)ret_conv;
29138 }
29139
29140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29141         LDKKeysManager this_obj_conv;
29142         this_obj_conv.inner = (void*)(this_obj & (~1));
29143         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29145         KeysManager_free(this_obj_conv);
29146 }
29147
29148 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) {
29149         unsigned char seed_arr[32];
29150         CHECK((*env)->GetArrayLength(env, seed) == 32);
29151         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
29152         unsigned char (*seed_ref)[32] = &seed_arr;
29153         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
29154         int64_t ret_ref = 0;
29155         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29156         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29158         ret_ref = (uintptr_t)ret_var.inner;
29159         if (ret_var.is_owned) {
29160                 ret_ref |= 1;
29161         }
29162         return ret_ref;
29163 }
29164
29165 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) {
29166         LDKKeysManager this_arg_conv;
29167         this_arg_conv.inner = (void*)(this_arg & (~1));
29168         this_arg_conv.is_owned = false;
29169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29170         unsigned char params_arr[32];
29171         CHECK((*env)->GetArrayLength(env, params) == 32);
29172         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
29173         unsigned char (*params_ref)[32] = &params_arr;
29174         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
29175         int64_t ret_ref = 0;
29176         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29177         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29179         ret_ref = (uintptr_t)ret_var.inner;
29180         if (ret_var.is_owned) {
29181                 ret_ref |= 1;
29182         }
29183         return ret_ref;
29184 }
29185
29186 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) {
29187         LDKKeysManager this_arg_conv;
29188         this_arg_conv.inner = (void*)(this_arg & (~1));
29189         this_arg_conv.is_owned = false;
29190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29191         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
29192         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
29193         if (descriptors_constr.datalen > 0)
29194                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
29195         else
29196                 descriptors_constr.data = NULL;
29197         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
29198         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
29199                 int64_t descriptors_conv_27 = descriptors_vals[b];
29200                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
29201                 CHECK_ACCESS(descriptors_conv_27_ptr);
29202                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
29203                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
29204                 descriptors_constr.data[b] = descriptors_conv_27_conv;
29205         }
29206         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
29207         LDKCVec_TxOutZ outputs_constr;
29208         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
29209         if (outputs_constr.datalen > 0)
29210                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
29211         else
29212                 outputs_constr.data = NULL;
29213         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
29214         for (size_t h = 0; h < outputs_constr.datalen; h++) {
29215                 int64_t outputs_conv_7 = outputs_vals[h];
29216                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
29217                 CHECK_ACCESS(outputs_conv_7_ptr);
29218                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
29219                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
29220                 outputs_constr.data[h] = outputs_conv_7_conv;
29221         }
29222         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
29223         LDKCVec_u8Z change_destination_script_ref;
29224         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
29225         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
29226         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
29227         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
29228         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
29229         return (int64_t)ret_conv;
29230 }
29231
29232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
29233         LDKKeysManager this_arg_conv;
29234         this_arg_conv.inner = (void*)(this_arg & (~1));
29235         this_arg_conv.is_owned = false;
29236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29237         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
29238         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
29239         return (int64_t)ret_ret;
29240 }
29241
29242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29243         LDKPhantomKeysManager this_obj_conv;
29244         this_obj_conv.inner = (void*)(this_obj & (~1));
29245         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29247         PhantomKeysManager_free(this_obj_conv);
29248 }
29249
29250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
29251         LDKPhantomKeysManager this_arg_conv;
29252         this_arg_conv.inner = (void*)(this_arg & (~1));
29253         this_arg_conv.is_owned = false;
29254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29255         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
29256         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
29257         return (int64_t)ret_ret;
29258 }
29259
29260 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) {
29261         unsigned char seed_arr[32];
29262         CHECK((*env)->GetArrayLength(env, seed) == 32);
29263         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
29264         unsigned char (*seed_ref)[32] = &seed_arr;
29265         unsigned char cross_node_seed_arr[32];
29266         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
29267         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
29268         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
29269         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
29270         int64_t ret_ref = 0;
29271         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29272         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29273         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29274         ret_ref = (uintptr_t)ret_var.inner;
29275         if (ret_var.is_owned) {
29276                 ret_ref |= 1;
29277         }
29278         return ret_ref;
29279 }
29280
29281 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) {
29282         LDKPhantomKeysManager this_arg_conv;
29283         this_arg_conv.inner = (void*)(this_arg & (~1));
29284         this_arg_conv.is_owned = false;
29285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29286         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
29287         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
29288         if (descriptors_constr.datalen > 0)
29289                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
29290         else
29291                 descriptors_constr.data = NULL;
29292         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
29293         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
29294                 int64_t descriptors_conv_27 = descriptors_vals[b];
29295                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
29296                 CHECK_ACCESS(descriptors_conv_27_ptr);
29297                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
29298                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
29299                 descriptors_constr.data[b] = descriptors_conv_27_conv;
29300         }
29301         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
29302         LDKCVec_TxOutZ outputs_constr;
29303         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
29304         if (outputs_constr.datalen > 0)
29305                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
29306         else
29307                 outputs_constr.data = NULL;
29308         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
29309         for (size_t h = 0; h < outputs_constr.datalen; h++) {
29310                 int64_t outputs_conv_7 = outputs_vals[h];
29311                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
29312                 CHECK_ACCESS(outputs_conv_7_ptr);
29313                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
29314                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
29315                 outputs_constr.data[h] = outputs_conv_7_conv;
29316         }
29317         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
29318         LDKCVec_u8Z change_destination_script_ref;
29319         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
29320         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
29321         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
29322         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
29323         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
29324         return (int64_t)ret_conv;
29325 }
29326
29327 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) {
29328         LDKPhantomKeysManager this_arg_conv;
29329         this_arg_conv.inner = (void*)(this_arg & (~1));
29330         this_arg_conv.is_owned = false;
29331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29332         unsigned char params_arr[32];
29333         CHECK((*env)->GetArrayLength(env, params) == 32);
29334         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
29335         unsigned char (*params_ref)[32] = &params_arr;
29336         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
29337         int64_t ret_ref = 0;
29338         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29339         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29341         ret_ref = (uintptr_t)ret_var.inner;
29342         if (ret_var.is_owned) {
29343                 ret_ref |= 1;
29344         }
29345         return ret_ref;
29346 }
29347
29348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29349         LDKChannelManager this_obj_conv;
29350         this_obj_conv.inner = (void*)(this_obj & (~1));
29351         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29353         ChannelManager_free(this_obj_conv);
29354 }
29355
29356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29357         LDKChainParameters this_obj_conv;
29358         this_obj_conv.inner = (void*)(this_obj & (~1));
29359         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29361         ChainParameters_free(this_obj_conv);
29362 }
29363
29364 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
29365         LDKChainParameters this_ptr_conv;
29366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29367         this_ptr_conv.is_owned = false;
29368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29369         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
29370         return ret_conv;
29371 }
29372
29373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
29374         LDKChainParameters this_ptr_conv;
29375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29376         this_ptr_conv.is_owned = false;
29377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29378         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
29379         ChainParameters_set_network(&this_ptr_conv, val_conv);
29380 }
29381
29382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
29383         LDKChainParameters this_ptr_conv;
29384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29385         this_ptr_conv.is_owned = false;
29386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29387         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
29388         int64_t ret_ref = 0;
29389         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29390         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29392         ret_ref = (uintptr_t)ret_var.inner;
29393         if (ret_var.is_owned) {
29394                 ret_ref |= 1;
29395         }
29396         return ret_ref;
29397 }
29398
29399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29400         LDKChainParameters this_ptr_conv;
29401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29402         this_ptr_conv.is_owned = false;
29403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29404         LDKBestBlock val_conv;
29405         val_conv.inner = (void*)(val & (~1));
29406         val_conv.is_owned = (val & 1) || (val == 0);
29407         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29408         val_conv = BestBlock_clone(&val_conv);
29409         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
29410 }
29411
29412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
29413         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
29414         LDKBestBlock best_block_arg_conv;
29415         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
29416         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
29417         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
29418         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
29419         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
29420         int64_t ret_ref = 0;
29421         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29422         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29424         ret_ref = (uintptr_t)ret_var.inner;
29425         if (ret_var.is_owned) {
29426                 ret_ref |= 1;
29427         }
29428         return ret_ref;
29429 }
29430
29431 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
29432         LDKChainParameters ret_var = ChainParameters_clone(arg);
29433 int64_t ret_ref = 0;
29434 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29435 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29436 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29437 ret_ref = (uintptr_t)ret_var.inner;
29438 if (ret_var.is_owned) {
29439         ret_ref |= 1;
29440 }
29441         return ret_ref;
29442 }
29443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29444         LDKChainParameters arg_conv;
29445         arg_conv.inner = (void*)(arg & (~1));
29446         arg_conv.is_owned = false;
29447         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29448         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
29449         return ret_conv;
29450 }
29451
29452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29453         LDKChainParameters orig_conv;
29454         orig_conv.inner = (void*)(orig & (~1));
29455         orig_conv.is_owned = false;
29456         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29457         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
29458         int64_t ret_ref = 0;
29459         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29460         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29462         ret_ref = (uintptr_t)ret_var.inner;
29463         if (ret_var.is_owned) {
29464                 ret_ref |= 1;
29465         }
29466         return ret_ref;
29467 }
29468
29469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29470         LDKCounterpartyForwardingInfo this_obj_conv;
29471         this_obj_conv.inner = (void*)(this_obj & (~1));
29472         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29474         CounterpartyForwardingInfo_free(this_obj_conv);
29475 }
29476
29477 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29478         LDKCounterpartyForwardingInfo this_ptr_conv;
29479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29480         this_ptr_conv.is_owned = false;
29481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29482         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
29483         return ret_conv;
29484 }
29485
29486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29487         LDKCounterpartyForwardingInfo this_ptr_conv;
29488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29489         this_ptr_conv.is_owned = false;
29490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29491         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
29492 }
29493
29494 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
29495         LDKCounterpartyForwardingInfo this_ptr_conv;
29496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29497         this_ptr_conv.is_owned = false;
29498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29499         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
29500         return ret_conv;
29501 }
29502
29503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29504         LDKCounterpartyForwardingInfo this_ptr_conv;
29505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29506         this_ptr_conv.is_owned = false;
29507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29508         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
29509 }
29510
29511 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
29512         LDKCounterpartyForwardingInfo this_ptr_conv;
29513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29514         this_ptr_conv.is_owned = false;
29515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29516         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
29517         return ret_conv;
29518 }
29519
29520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29521         LDKCounterpartyForwardingInfo this_ptr_conv;
29522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29523         this_ptr_conv.is_owned = false;
29524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29525         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
29526 }
29527
29528 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) {
29529         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
29530         int64_t ret_ref = 0;
29531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29534         ret_ref = (uintptr_t)ret_var.inner;
29535         if (ret_var.is_owned) {
29536                 ret_ref |= 1;
29537         }
29538         return ret_ref;
29539 }
29540
29541 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
29542         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
29543 int64_t ret_ref = 0;
29544 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29545 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29546 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29547 ret_ref = (uintptr_t)ret_var.inner;
29548 if (ret_var.is_owned) {
29549         ret_ref |= 1;
29550 }
29551         return ret_ref;
29552 }
29553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29554         LDKCounterpartyForwardingInfo arg_conv;
29555         arg_conv.inner = (void*)(arg & (~1));
29556         arg_conv.is_owned = false;
29557         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29558         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
29559         return ret_conv;
29560 }
29561
29562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29563         LDKCounterpartyForwardingInfo orig_conv;
29564         orig_conv.inner = (void*)(orig & (~1));
29565         orig_conv.is_owned = false;
29566         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29567         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
29568         int64_t ret_ref = 0;
29569         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29570         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29571         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29572         ret_ref = (uintptr_t)ret_var.inner;
29573         if (ret_var.is_owned) {
29574                 ret_ref |= 1;
29575         }
29576         return ret_ref;
29577 }
29578
29579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29580         LDKChannelCounterparty this_obj_conv;
29581         this_obj_conv.inner = (void*)(this_obj & (~1));
29582         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29584         ChannelCounterparty_free(this_obj_conv);
29585 }
29586
29587 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29588         LDKChannelCounterparty this_ptr_conv;
29589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29590         this_ptr_conv.is_owned = false;
29591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29592         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29593         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
29594         return ret_arr;
29595 }
29596
29597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29598         LDKChannelCounterparty this_ptr_conv;
29599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29600         this_ptr_conv.is_owned = false;
29601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29602         LDKPublicKey val_ref;
29603         CHECK((*env)->GetArrayLength(env, val) == 33);
29604         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29605         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
29606 }
29607
29608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
29609         LDKChannelCounterparty this_ptr_conv;
29610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29611         this_ptr_conv.is_owned = false;
29612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29613         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
29614         int64_t ret_ref = 0;
29615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29618         ret_ref = (uintptr_t)ret_var.inner;
29619         if (ret_var.is_owned) {
29620                 ret_ref |= 1;
29621         }
29622         return ret_ref;
29623 }
29624
29625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29626         LDKChannelCounterparty this_ptr_conv;
29627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29628         this_ptr_conv.is_owned = false;
29629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29630         LDKInitFeatures val_conv;
29631         val_conv.inner = (void*)(val & (~1));
29632         val_conv.is_owned = (val & 1) || (val == 0);
29633         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29634         val_conv = InitFeatures_clone(&val_conv);
29635         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
29636 }
29637
29638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
29639         LDKChannelCounterparty this_ptr_conv;
29640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29641         this_ptr_conv.is_owned = false;
29642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29643         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
29644         return ret_conv;
29645 }
29646
29647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29648         LDKChannelCounterparty this_ptr_conv;
29649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29650         this_ptr_conv.is_owned = false;
29651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29652         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
29653 }
29654
29655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
29656         LDKChannelCounterparty this_ptr_conv;
29657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29658         this_ptr_conv.is_owned = false;
29659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29660         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
29661         int64_t ret_ref = 0;
29662         if ((uintptr_t)ret_var.inner > 4096) {
29663                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29664                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29666                 ret_ref = (uintptr_t)ret_var.inner;
29667                 if (ret_var.is_owned) {
29668                         ret_ref |= 1;
29669                 }
29670         }
29671         return ret_ref;
29672 }
29673
29674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29675         LDKChannelCounterparty this_ptr_conv;
29676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29677         this_ptr_conv.is_owned = false;
29678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29679         LDKCounterpartyForwardingInfo val_conv;
29680         val_conv.inner = (void*)(val & (~1));
29681         val_conv.is_owned = (val & 1) || (val == 0);
29682         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29683         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
29684         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
29685 }
29686
29687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29688         LDKChannelCounterparty this_ptr_conv;
29689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29690         this_ptr_conv.is_owned = false;
29691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29692         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29693         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
29694         int64_t ret_ref = (uintptr_t)ret_copy;
29695         return ret_ref;
29696 }
29697
29698 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) {
29699         LDKChannelCounterparty this_ptr_conv;
29700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29701         this_ptr_conv.is_owned = false;
29702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29703         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29704         CHECK_ACCESS(val_ptr);
29705         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29706         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29707         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
29708 }
29709
29710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29711         LDKChannelCounterparty this_ptr_conv;
29712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29713         this_ptr_conv.is_owned = false;
29714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29715         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29716         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
29717         int64_t ret_ref = (uintptr_t)ret_copy;
29718         return ret_ref;
29719 }
29720
29721 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) {
29722         LDKChannelCounterparty this_ptr_conv;
29723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29724         this_ptr_conv.is_owned = false;
29725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29726         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29727         CHECK_ACCESS(val_ptr);
29728         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29729         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29730         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
29731 }
29732
29733 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) {
29734         LDKPublicKey node_id_arg_ref;
29735         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
29736         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
29737         LDKInitFeatures features_arg_conv;
29738         features_arg_conv.inner = (void*)(features_arg & (~1));
29739         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
29740         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
29741         features_arg_conv = InitFeatures_clone(&features_arg_conv);
29742         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
29743         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
29744         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
29745         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
29746         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
29747         void* outbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1);
29748         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
29749         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
29750         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1));
29751         void* outbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1);
29752         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
29753         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
29754         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1));
29755         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);
29756         int64_t ret_ref = 0;
29757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29760         ret_ref = (uintptr_t)ret_var.inner;
29761         if (ret_var.is_owned) {
29762                 ret_ref |= 1;
29763         }
29764         return ret_ref;
29765 }
29766
29767 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
29768         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
29769 int64_t ret_ref = 0;
29770 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29771 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29772 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29773 ret_ref = (uintptr_t)ret_var.inner;
29774 if (ret_var.is_owned) {
29775         ret_ref |= 1;
29776 }
29777         return ret_ref;
29778 }
29779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29780         LDKChannelCounterparty arg_conv;
29781         arg_conv.inner = (void*)(arg & (~1));
29782         arg_conv.is_owned = false;
29783         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29784         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
29785         return ret_conv;
29786 }
29787
29788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29789         LDKChannelCounterparty orig_conv;
29790         orig_conv.inner = (void*)(orig & (~1));
29791         orig_conv.is_owned = false;
29792         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29793         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
29794         int64_t ret_ref = 0;
29795         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29796         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29798         ret_ref = (uintptr_t)ret_var.inner;
29799         if (ret_var.is_owned) {
29800                 ret_ref |= 1;
29801         }
29802         return ret_ref;
29803 }
29804
29805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29806         LDKChannelDetails this_obj_conv;
29807         this_obj_conv.inner = (void*)(this_obj & (~1));
29808         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29810         ChannelDetails_free(this_obj_conv);
29811 }
29812
29813 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29814         LDKChannelDetails this_ptr_conv;
29815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29816         this_ptr_conv.is_owned = false;
29817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29818         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29819         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
29820         return ret_arr;
29821 }
29822
29823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29824         LDKChannelDetails this_ptr_conv;
29825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29826         this_ptr_conv.is_owned = false;
29827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29828         LDKThirtyTwoBytes val_ref;
29829         CHECK((*env)->GetArrayLength(env, val) == 32);
29830         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29831         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
29832 }
29833
29834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
29835         LDKChannelDetails this_ptr_conv;
29836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29837         this_ptr_conv.is_owned = false;
29838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29839         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
29840         int64_t ret_ref = 0;
29841         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29842         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29844         ret_ref = (uintptr_t)ret_var.inner;
29845         if (ret_var.is_owned) {
29846                 ret_ref |= 1;
29847         }
29848         return ret_ref;
29849 }
29850
29851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29852         LDKChannelDetails this_ptr_conv;
29853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29854         this_ptr_conv.is_owned = false;
29855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29856         LDKChannelCounterparty val_conv;
29857         val_conv.inner = (void*)(val & (~1));
29858         val_conv.is_owned = (val & 1) || (val == 0);
29859         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29860         val_conv = ChannelCounterparty_clone(&val_conv);
29861         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
29862 }
29863
29864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
29865         LDKChannelDetails this_ptr_conv;
29866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29867         this_ptr_conv.is_owned = false;
29868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29869         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
29870         int64_t ret_ref = 0;
29871         if ((uintptr_t)ret_var.inner > 4096) {
29872                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29873                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29875                 ret_ref = (uintptr_t)ret_var.inner;
29876                 if (ret_var.is_owned) {
29877                         ret_ref |= 1;
29878                 }
29879         }
29880         return ret_ref;
29881 }
29882
29883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29884         LDKChannelDetails this_ptr_conv;
29885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29886         this_ptr_conv.is_owned = false;
29887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29888         LDKOutPoint val_conv;
29889         val_conv.inner = (void*)(val & (~1));
29890         val_conv.is_owned = (val & 1) || (val == 0);
29891         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29892         val_conv = OutPoint_clone(&val_conv);
29893         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
29894 }
29895
29896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
29897         LDKChannelDetails this_ptr_conv;
29898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29899         this_ptr_conv.is_owned = false;
29900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29901         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
29902         int64_t ret_ref = 0;
29903         if ((uintptr_t)ret_var.inner > 4096) {
29904                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29905                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29907                 ret_ref = (uintptr_t)ret_var.inner;
29908                 if (ret_var.is_owned) {
29909                         ret_ref |= 1;
29910                 }
29911         }
29912         return ret_ref;
29913 }
29914
29915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29916         LDKChannelDetails this_ptr_conv;
29917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29918         this_ptr_conv.is_owned = false;
29919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29920         LDKChannelTypeFeatures val_conv;
29921         val_conv.inner = (void*)(val & (~1));
29922         val_conv.is_owned = (val & 1) || (val == 0);
29923         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29924         val_conv = ChannelTypeFeatures_clone(&val_conv);
29925         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
29926 }
29927
29928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29929         LDKChannelDetails this_ptr_conv;
29930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29931         this_ptr_conv.is_owned = false;
29932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29933         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29934         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
29935         int64_t ret_ref = (uintptr_t)ret_copy;
29936         return ret_ref;
29937 }
29938
29939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29940         LDKChannelDetails this_ptr_conv;
29941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29942         this_ptr_conv.is_owned = false;
29943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29944         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29945         CHECK_ACCESS(val_ptr);
29946         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29947         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29948         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
29949 }
29950
29951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
29952         LDKChannelDetails this_ptr_conv;
29953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29954         this_ptr_conv.is_owned = false;
29955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29956         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29957         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
29958         int64_t ret_ref = (uintptr_t)ret_copy;
29959         return ret_ref;
29960 }
29961
29962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29963         LDKChannelDetails this_ptr_conv;
29964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29965         this_ptr_conv.is_owned = false;
29966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29967         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29968         CHECK_ACCESS(val_ptr);
29969         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29970         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29971         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
29972 }
29973
29974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
29975         LDKChannelDetails this_ptr_conv;
29976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29977         this_ptr_conv.is_owned = false;
29978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29979         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29980         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
29981         int64_t ret_ref = (uintptr_t)ret_copy;
29982         return ret_ref;
29983 }
29984
29985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29986         LDKChannelDetails this_ptr_conv;
29987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29988         this_ptr_conv.is_owned = false;
29989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29990         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29991         CHECK_ACCESS(val_ptr);
29992         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29993         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29994         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
29995 }
29996
29997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29998         LDKChannelDetails this_ptr_conv;
29999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30000         this_ptr_conv.is_owned = false;
30001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30002         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
30003         return ret_conv;
30004 }
30005
30006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30007         LDKChannelDetails this_ptr_conv;
30008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30009         this_ptr_conv.is_owned = false;
30010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30011         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
30012 }
30013
30014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
30015         LDKChannelDetails this_ptr_conv;
30016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30017         this_ptr_conv.is_owned = false;
30018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30019         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30020         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
30021         int64_t ret_ref = (uintptr_t)ret_copy;
30022         return ret_ref;
30023 }
30024
30025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30026         LDKChannelDetails this_ptr_conv;
30027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30028         this_ptr_conv.is_owned = false;
30029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30030         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30031         CHECK_ACCESS(val_ptr);
30032         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30033         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
30034         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
30035 }
30036
30037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30038         LDKChannelDetails this_ptr_conv;
30039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30040         this_ptr_conv.is_owned = false;
30041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30042         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
30043         return ret_conv;
30044 }
30045
30046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30047         LDKChannelDetails this_ptr_conv;
30048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30049         this_ptr_conv.is_owned = false;
30050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30051         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
30052 }
30053
30054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30055         LDKChannelDetails this_ptr_conv;
30056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30057         this_ptr_conv.is_owned = false;
30058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30059         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
30060         return ret_conv;
30061 }
30062
30063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30064         LDKChannelDetails this_ptr_conv;
30065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30066         this_ptr_conv.is_owned = false;
30067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30068         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
30069 }
30070
30071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30072         LDKChannelDetails this_ptr_conv;
30073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30074         this_ptr_conv.is_owned = false;
30075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30076         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
30077         return ret_conv;
30078 }
30079
30080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30081         LDKChannelDetails this_ptr_conv;
30082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30083         this_ptr_conv.is_owned = false;
30084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30085         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
30086 }
30087
30088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30089         LDKChannelDetails this_ptr_conv;
30090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30091         this_ptr_conv.is_owned = false;
30092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30093         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
30094         return ret_conv;
30095 }
30096
30097 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) {
30098         LDKChannelDetails this_ptr_conv;
30099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30100         this_ptr_conv.is_owned = false;
30101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30102         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
30103 }
30104
30105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30106         LDKChannelDetails this_ptr_conv;
30107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30108         this_ptr_conv.is_owned = false;
30109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30110         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
30111         return ret_conv;
30112 }
30113
30114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30115         LDKChannelDetails this_ptr_conv;
30116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30117         this_ptr_conv.is_owned = false;
30118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30119         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
30120 }
30121
30122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
30123         LDKChannelDetails this_ptr_conv;
30124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30125         this_ptr_conv.is_owned = false;
30126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30127         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
30128         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
30129         int64_t ret_ref = (uintptr_t)ret_copy;
30130         return ret_ref;
30131 }
30132
30133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30134         LDKChannelDetails this_ptr_conv;
30135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30136         this_ptr_conv.is_owned = false;
30137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30138         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30139         CHECK_ACCESS(val_ptr);
30140         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
30141         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
30142         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
30143 }
30144
30145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30146         LDKChannelDetails this_ptr_conv;
30147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30148         this_ptr_conv.is_owned = false;
30149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30150         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
30151         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
30152         int64_t ret_ref = (uintptr_t)ret_copy;
30153         return ret_ref;
30154 }
30155
30156 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) {
30157         LDKChannelDetails this_ptr_conv;
30158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30159         this_ptr_conv.is_owned = false;
30160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30161         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30162         CHECK_ACCESS(val_ptr);
30163         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
30164         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
30165         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
30166 }
30167
30168 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
30169         LDKChannelDetails this_ptr_conv;
30170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30171         this_ptr_conv.is_owned = false;
30172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30173         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
30174         return ret_conv;
30175 }
30176
30177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30178         LDKChannelDetails this_ptr_conv;
30179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30180         this_ptr_conv.is_owned = false;
30181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30182         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
30183 }
30184
30185 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr) {
30186         LDKChannelDetails this_ptr_conv;
30187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30188         this_ptr_conv.is_owned = false;
30189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30190         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
30191         return ret_conv;
30192 }
30193
30194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30195         LDKChannelDetails this_ptr_conv;
30196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30197         this_ptr_conv.is_owned = false;
30198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30199         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
30200 }
30201
30202 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
30203         LDKChannelDetails this_ptr_conv;
30204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30205         this_ptr_conv.is_owned = false;
30206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30207         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
30208         return ret_conv;
30209 }
30210
30211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30212         LDKChannelDetails this_ptr_conv;
30213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30214         this_ptr_conv.is_owned = false;
30215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30216         ChannelDetails_set_is_usable(&this_ptr_conv, val);
30217 }
30218
30219 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
30220         LDKChannelDetails this_ptr_conv;
30221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30222         this_ptr_conv.is_owned = false;
30223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30224         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
30225         return ret_conv;
30226 }
30227
30228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30229         LDKChannelDetails this_ptr_conv;
30230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30231         this_ptr_conv.is_owned = false;
30232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30233         ChannelDetails_set_is_public(&this_ptr_conv, val);
30234 }
30235
30236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30237         LDKChannelDetails this_ptr_conv;
30238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30239         this_ptr_conv.is_owned = false;
30240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30241         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30242         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
30243         int64_t ret_ref = (uintptr_t)ret_copy;
30244         return ret_ref;
30245 }
30246
30247 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) {
30248         LDKChannelDetails this_ptr_conv;
30249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30250         this_ptr_conv.is_owned = false;
30251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30252         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30253         CHECK_ACCESS(val_ptr);
30254         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30255         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
30256         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
30257 }
30258
30259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30260         LDKChannelDetails this_ptr_conv;
30261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30262         this_ptr_conv.is_owned = false;
30263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30264         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30265         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
30266         int64_t ret_ref = (uintptr_t)ret_copy;
30267         return ret_ref;
30268 }
30269
30270 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) {
30271         LDKChannelDetails this_ptr_conv;
30272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30273         this_ptr_conv.is_owned = false;
30274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30275         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30276         CHECK_ACCESS(val_ptr);
30277         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30278         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
30279         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
30280 }
30281
30282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
30283         LDKChannelDetails this_ptr_conv;
30284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30285         this_ptr_conv.is_owned = false;
30286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30287         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
30288         int64_t ret_ref = 0;
30289         if ((uintptr_t)ret_var.inner > 4096) {
30290                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30291                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30293                 ret_ref = (uintptr_t)ret_var.inner;
30294                 if (ret_var.is_owned) {
30295                         ret_ref |= 1;
30296                 }
30297         }
30298         return ret_ref;
30299 }
30300
30301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30302         LDKChannelDetails this_ptr_conv;
30303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30304         this_ptr_conv.is_owned = false;
30305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30306         LDKChannelConfig val_conv;
30307         val_conv.inner = (void*)(val & (~1));
30308         val_conv.is_owned = (val & 1) || (val == 0);
30309         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30310         val_conv = ChannelConfig_clone(&val_conv);
30311         ChannelDetails_set_config(&this_ptr_conv, val_conv);
30312 }
30313
30314 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, int64_t config_arg) {
30315         LDKThirtyTwoBytes channel_id_arg_ref;
30316         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30317         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30318         LDKChannelCounterparty counterparty_arg_conv;
30319         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
30320         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
30321         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
30322         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
30323         LDKOutPoint funding_txo_arg_conv;
30324         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
30325         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
30326         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
30327         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
30328         LDKChannelTypeFeatures channel_type_arg_conv;
30329         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
30330         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
30331         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
30332         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
30333         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
30334         CHECK_ACCESS(short_channel_id_arg_ptr);
30335         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
30336         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
30337         void* outbound_scid_alias_arg_ptr = (void*)(((uintptr_t)outbound_scid_alias_arg) & ~1);
30338         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
30339         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
30340         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_scid_alias_arg) & ~1));
30341         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
30342         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
30343         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
30344         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
30345         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
30346         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
30347         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
30348         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
30349         CHECK_ACCESS(confirmations_required_arg_ptr);
30350         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
30351         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
30352         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
30353         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
30354         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
30355         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
30356         void* inbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1);
30357         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
30358         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
30359         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1));
30360         void* inbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1);
30361         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
30362         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
30363         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1));
30364         LDKChannelConfig config_arg_conv;
30365         config_arg_conv.inner = (void*)(config_arg & (~1));
30366         config_arg_conv.is_owned = (config_arg & 1) || (config_arg == 0);
30367         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
30368         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
30369         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, config_arg_conv);
30370         int64_t ret_ref = 0;
30371         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30372         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30374         ret_ref = (uintptr_t)ret_var.inner;
30375         if (ret_var.is_owned) {
30376                 ret_ref |= 1;
30377         }
30378         return ret_ref;
30379 }
30380
30381 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
30382         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
30383 int64_t ret_ref = 0;
30384 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30385 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30386 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30387 ret_ref = (uintptr_t)ret_var.inner;
30388 if (ret_var.is_owned) {
30389         ret_ref |= 1;
30390 }
30391         return ret_ref;
30392 }
30393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30394         LDKChannelDetails arg_conv;
30395         arg_conv.inner = (void*)(arg & (~1));
30396         arg_conv.is_owned = false;
30397         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30398         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
30399         return ret_conv;
30400 }
30401
30402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30403         LDKChannelDetails orig_conv;
30404         orig_conv.inner = (void*)(orig & (~1));
30405         orig_conv.is_owned = false;
30406         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30407         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
30408         int64_t ret_ref = 0;
30409         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30410         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30412         ret_ref = (uintptr_t)ret_var.inner;
30413         if (ret_var.is_owned) {
30414                 ret_ref |= 1;
30415         }
30416         return ret_ref;
30417 }
30418
30419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
30420         LDKChannelDetails this_arg_conv;
30421         this_arg_conv.inner = (void*)(this_arg & (~1));
30422         this_arg_conv.is_owned = false;
30423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30424         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30425         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
30426         int64_t ret_ref = (uintptr_t)ret_copy;
30427         return ret_ref;
30428 }
30429
30430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
30431         LDKChannelDetails this_arg_conv;
30432         this_arg_conv.inner = (void*)(this_arg & (~1));
30433         this_arg_conv.is_owned = false;
30434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30435         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30436         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
30437         int64_t ret_ref = (uintptr_t)ret_copy;
30438         return ret_ref;
30439 }
30440
30441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30442         if ((this_ptr & 1) != 0) return;
30443         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
30444         CHECK_ACCESS(this_ptr_ptr);
30445         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
30446         FREE((void*)this_ptr);
30447         PaymentSendFailure_free(this_ptr_conv);
30448 }
30449
30450 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
30451         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30452         *ret_copy = PaymentSendFailure_clone(arg);
30453 int64_t ret_ref = (uintptr_t)ret_copy;
30454         return ret_ref;
30455 }
30456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30457         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
30458         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
30459         return ret_conv;
30460 }
30461
30462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30463         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
30464         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30465         *ret_copy = PaymentSendFailure_clone(orig_conv);
30466         int64_t ret_ref = (uintptr_t)ret_copy;
30467         return ret_ref;
30468 }
30469
30470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
30471         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
30472         CHECK_ACCESS(a_ptr);
30473         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
30474         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
30475         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30476         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
30477         int64_t ret_ref = (uintptr_t)ret_copy;
30478         return ret_ref;
30479 }
30480
30481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
30482         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
30483         a_constr.datalen = (*env)->GetArrayLength(env, a);
30484         if (a_constr.datalen > 0)
30485                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
30486         else
30487                 a_constr.data = NULL;
30488         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
30489         for (size_t w = 0; w < a_constr.datalen; w++) {
30490                 int64_t a_conv_22 = a_vals[w];
30491                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
30492                 CHECK_ACCESS(a_conv_22_ptr);
30493                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
30494                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
30495                 a_constr.data[w] = a_conv_22_conv;
30496         }
30497         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
30498         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30499         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
30500         int64_t ret_ref = (uintptr_t)ret_copy;
30501         return ret_ref;
30502 }
30503
30504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
30505         LDKCVec_APIErrorZ a_constr;
30506         a_constr.datalen = (*env)->GetArrayLength(env, a);
30507         if (a_constr.datalen > 0)
30508                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
30509         else
30510                 a_constr.data = NULL;
30511         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
30512         for (size_t k = 0; k < a_constr.datalen; k++) {
30513                 int64_t a_conv_10 = a_vals[k];
30514                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
30515                 CHECK_ACCESS(a_conv_10_ptr);
30516                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
30517                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
30518                 a_constr.data[k] = a_conv_10_conv;
30519         }
30520         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
30521         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30522         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
30523         int64_t ret_ref = (uintptr_t)ret_copy;
30524         return ret_ref;
30525 }
30526
30527 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) {
30528         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
30529         results_constr.datalen = (*env)->GetArrayLength(env, results);
30530         if (results_constr.datalen > 0)
30531                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
30532         else
30533                 results_constr.data = NULL;
30534         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
30535         for (size_t w = 0; w < results_constr.datalen; w++) {
30536                 int64_t results_conv_22 = results_vals[w];
30537                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
30538                 CHECK_ACCESS(results_conv_22_ptr);
30539                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
30540                 results_constr.data[w] = results_conv_22_conv;
30541         }
30542         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
30543         LDKRouteParameters failed_paths_retry_conv;
30544         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
30545         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
30546         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
30547         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
30548         LDKThirtyTwoBytes payment_id_ref;
30549         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
30550         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
30551         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30552         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
30553         int64_t ret_ref = (uintptr_t)ret_copy;
30554         return ret_ref;
30555 }
30556
30557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30558         LDKPhantomRouteHints this_obj_conv;
30559         this_obj_conv.inner = (void*)(this_obj & (~1));
30560         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30562         PhantomRouteHints_free(this_obj_conv);
30563 }
30564
30565 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
30566         LDKPhantomRouteHints this_ptr_conv;
30567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30568         this_ptr_conv.is_owned = false;
30569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30570         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
30571         int64_tArray ret_arr = NULL;
30572         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30573         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30574         for (size_t q = 0; q < ret_var.datalen; q++) {
30575                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
30576                 int64_t ret_conv_16_ref = 0;
30577                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30578                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30579                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30580                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30581                 if (ret_conv_16_var.is_owned) {
30582                         ret_conv_16_ref |= 1;
30583                 }
30584                 ret_arr_ptr[q] = ret_conv_16_ref;
30585         }
30586         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30587         FREE(ret_var.data);
30588         return ret_arr;
30589 }
30590
30591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
30592         LDKPhantomRouteHints this_ptr_conv;
30593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30594         this_ptr_conv.is_owned = false;
30595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30596         LDKCVec_ChannelDetailsZ val_constr;
30597         val_constr.datalen = (*env)->GetArrayLength(env, val);
30598         if (val_constr.datalen > 0)
30599                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
30600         else
30601                 val_constr.data = NULL;
30602         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
30603         for (size_t q = 0; q < val_constr.datalen; q++) {
30604                 int64_t val_conv_16 = val_vals[q];
30605                 LDKChannelDetails val_conv_16_conv;
30606                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
30607                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
30608                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
30609                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
30610                 val_constr.data[q] = val_conv_16_conv;
30611         }
30612         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
30613         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
30614 }
30615
30616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
30617         LDKPhantomRouteHints this_ptr_conv;
30618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30619         this_ptr_conv.is_owned = false;
30620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30621         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
30622         return ret_conv;
30623 }
30624
30625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30626         LDKPhantomRouteHints this_ptr_conv;
30627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30628         this_ptr_conv.is_owned = false;
30629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30630         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
30631 }
30632
30633 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30634         LDKPhantomRouteHints this_ptr_conv;
30635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30636         this_ptr_conv.is_owned = false;
30637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30638         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30639         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
30640         return ret_arr;
30641 }
30642
30643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30644         LDKPhantomRouteHints this_ptr_conv;
30645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30646         this_ptr_conv.is_owned = false;
30647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30648         LDKPublicKey val_ref;
30649         CHECK((*env)->GetArrayLength(env, val) == 33);
30650         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30651         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
30652 }
30653
30654 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) {
30655         LDKCVec_ChannelDetailsZ channels_arg_constr;
30656         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
30657         if (channels_arg_constr.datalen > 0)
30658                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
30659         else
30660                 channels_arg_constr.data = NULL;
30661         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
30662         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
30663                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
30664                 LDKChannelDetails channels_arg_conv_16_conv;
30665                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
30666                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
30667                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
30668                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
30669                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
30670         }
30671         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
30672         LDKPublicKey real_node_pubkey_arg_ref;
30673         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
30674         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
30675         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
30676         int64_t ret_ref = 0;
30677         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30678         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30680         ret_ref = (uintptr_t)ret_var.inner;
30681         if (ret_var.is_owned) {
30682                 ret_ref |= 1;
30683         }
30684         return ret_ref;
30685 }
30686
30687 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
30688         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
30689 int64_t ret_ref = 0;
30690 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30691 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30692 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30693 ret_ref = (uintptr_t)ret_var.inner;
30694 if (ret_var.is_owned) {
30695         ret_ref |= 1;
30696 }
30697         return ret_ref;
30698 }
30699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30700         LDKPhantomRouteHints arg_conv;
30701         arg_conv.inner = (void*)(arg & (~1));
30702         arg_conv.is_owned = false;
30703         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30704         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
30705         return ret_conv;
30706 }
30707
30708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30709         LDKPhantomRouteHints orig_conv;
30710         orig_conv.inner = (void*)(orig & (~1));
30711         orig_conv.is_owned = false;
30712         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30713         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
30714         int64_t ret_ref = 0;
30715         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30716         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30718         ret_ref = (uintptr_t)ret_var.inner;
30719         if (ret_var.is_owned) {
30720                 ret_ref |= 1;
30721         }
30722         return ret_ref;
30723 }
30724
30725 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) {
30726         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
30727         CHECK_ACCESS(fee_est_ptr);
30728         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
30729         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
30730                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30731                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
30732         }
30733         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
30734         CHECK_ACCESS(chain_monitor_ptr);
30735         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
30736         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
30737                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30738                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
30739         }
30740         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
30741         CHECK_ACCESS(tx_broadcaster_ptr);
30742         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
30743         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30744                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30745                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
30746         }
30747         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
30748         CHECK_ACCESS(logger_ptr);
30749         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30750         if (logger_conv.free == LDKLogger_JCalls_free) {
30751                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30752                 LDKLogger_JCalls_cloned(&logger_conv);
30753         }
30754         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
30755         CHECK_ACCESS(keys_manager_ptr);
30756         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
30757         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
30758                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30759                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
30760         }
30761         LDKUserConfig config_conv;
30762         config_conv.inner = (void*)(config & (~1));
30763         config_conv.is_owned = (config & 1) || (config == 0);
30764         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
30765         config_conv = UserConfig_clone(&config_conv);
30766         LDKChainParameters params_conv;
30767         params_conv.inner = (void*)(params & (~1));
30768         params_conv.is_owned = (params & 1) || (params == 0);
30769         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
30770         params_conv = ChainParameters_clone(&params_conv);
30771         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
30772         int64_t ret_ref = 0;
30773         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30774         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30776         ret_ref = (uintptr_t)ret_var.inner;
30777         if (ret_var.is_owned) {
30778                 ret_ref |= 1;
30779         }
30780         return ret_ref;
30781 }
30782
30783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
30784         LDKChannelManager this_arg_conv;
30785         this_arg_conv.inner = (void*)(this_arg & (~1));
30786         this_arg_conv.is_owned = false;
30787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30788         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
30789         int64_t ret_ref = 0;
30790         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30791         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30793         ret_ref = (uintptr_t)ret_var.inner;
30794         if (ret_var.is_owned) {
30795                 ret_ref |= 1;
30796         }
30797         return ret_ref;
30798 }
30799
30800 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) {
30801         LDKChannelManager this_arg_conv;
30802         this_arg_conv.inner = (void*)(this_arg & (~1));
30803         this_arg_conv.is_owned = false;
30804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30805         LDKPublicKey their_network_key_ref;
30806         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
30807         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
30808         LDKUserConfig override_config_conv;
30809         override_config_conv.inner = (void*)(override_config & (~1));
30810         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
30811         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
30812         override_config_conv = UserConfig_clone(&override_config_conv);
30813         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
30814         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
30815         return (int64_t)ret_conv;
30816 }
30817
30818 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
30819         LDKChannelManager this_arg_conv;
30820         this_arg_conv.inner = (void*)(this_arg & (~1));
30821         this_arg_conv.is_owned = false;
30822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30823         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
30824         int64_tArray ret_arr = NULL;
30825         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30826         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30827         for (size_t q = 0; q < ret_var.datalen; q++) {
30828                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
30829                 int64_t ret_conv_16_ref = 0;
30830                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30831                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30832                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30833                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30834                 if (ret_conv_16_var.is_owned) {
30835                         ret_conv_16_ref |= 1;
30836                 }
30837                 ret_arr_ptr[q] = ret_conv_16_ref;
30838         }
30839         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30840         FREE(ret_var.data);
30841         return ret_arr;
30842 }
30843
30844 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
30845         LDKChannelManager this_arg_conv;
30846         this_arg_conv.inner = (void*)(this_arg & (~1));
30847         this_arg_conv.is_owned = false;
30848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30849         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
30850         int64_tArray ret_arr = NULL;
30851         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30852         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30853         for (size_t q = 0; q < ret_var.datalen; q++) {
30854                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
30855                 int64_t ret_conv_16_ref = 0;
30856                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30857                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30858                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30859                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30860                 if (ret_conv_16_var.is_owned) {
30861                         ret_conv_16_ref |= 1;
30862                 }
30863                 ret_arr_ptr[q] = ret_conv_16_ref;
30864         }
30865         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30866         FREE(ret_var.data);
30867         return ret_arr;
30868 }
30869
30870 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) {
30871         LDKChannelManager this_arg_conv;
30872         this_arg_conv.inner = (void*)(this_arg & (~1));
30873         this_arg_conv.is_owned = false;
30874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30875         unsigned char channel_id_arr[32];
30876         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30877         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30878         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30879         LDKPublicKey counterparty_node_id_ref;
30880         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30881         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30882         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30883         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
30884         return (int64_t)ret_conv;
30885 }
30886
30887 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) {
30888         LDKChannelManager this_arg_conv;
30889         this_arg_conv.inner = (void*)(this_arg & (~1));
30890         this_arg_conv.is_owned = false;
30891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30892         unsigned char channel_id_arr[32];
30893         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30894         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30895         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30896         LDKPublicKey counterparty_node_id_ref;
30897         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30898         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30899         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30900         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
30901         return (int64_t)ret_conv;
30902 }
30903
30904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
30905         LDKChannelManager this_arg_conv;
30906         this_arg_conv.inner = (void*)(this_arg & (~1));
30907         this_arg_conv.is_owned = false;
30908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30909         unsigned char channel_id_arr[32];
30910         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30911         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30912         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30913         LDKPublicKey counterparty_node_id_ref;
30914         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30915         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30916         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30917         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
30918         return (int64_t)ret_conv;
30919 }
30920
30921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
30922         LDKChannelManager this_arg_conv;
30923         this_arg_conv.inner = (void*)(this_arg & (~1));
30924         this_arg_conv.is_owned = false;
30925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30926         unsigned char channel_id_arr[32];
30927         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30928         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30929         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30930         LDKPublicKey counterparty_node_id_ref;
30931         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30932         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30933         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30934         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
30935         return (int64_t)ret_conv;
30936 }
30937
30938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
30939         LDKChannelManager this_arg_conv;
30940         this_arg_conv.inner = (void*)(this_arg & (~1));
30941         this_arg_conv.is_owned = false;
30942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30943         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
30944 }
30945
30946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
30947         LDKChannelManager this_arg_conv;
30948         this_arg_conv.inner = (void*)(this_arg & (~1));
30949         this_arg_conv.is_owned = false;
30950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30951         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
30952 }
30953
30954 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) {
30955         LDKChannelManager this_arg_conv;
30956         this_arg_conv.inner = (void*)(this_arg & (~1));
30957         this_arg_conv.is_owned = false;
30958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30959         LDKRoute route_conv;
30960         route_conv.inner = (void*)(route & (~1));
30961         route_conv.is_owned = false;
30962         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
30963         LDKThirtyTwoBytes payment_hash_ref;
30964         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30965         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
30966         LDKThirtyTwoBytes payment_secret_ref;
30967         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
30968         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
30969         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
30970         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
30971         return (int64_t)ret_conv;
30972 }
30973
30974 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) {
30975         LDKChannelManager this_arg_conv;
30976         this_arg_conv.inner = (void*)(this_arg & (~1));
30977         this_arg_conv.is_owned = false;
30978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30979         LDKRoute route_conv;
30980         route_conv.inner = (void*)(route & (~1));
30981         route_conv.is_owned = false;
30982         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
30983         LDKThirtyTwoBytes payment_id_ref;
30984         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
30985         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
30986         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
30987         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
30988         return (int64_t)ret_conv;
30989 }
30990
30991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
30992         LDKChannelManager this_arg_conv;
30993         this_arg_conv.inner = (void*)(this_arg & (~1));
30994         this_arg_conv.is_owned = false;
30995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30996         LDKThirtyTwoBytes payment_id_ref;
30997         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
30998         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
30999         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
31000 }
31001
31002 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) {
31003         LDKChannelManager this_arg_conv;
31004         this_arg_conv.inner = (void*)(this_arg & (~1));
31005         this_arg_conv.is_owned = false;
31006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31007         LDKRoute route_conv;
31008         route_conv.inner = (void*)(route & (~1));
31009         route_conv.is_owned = false;
31010         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
31011         LDKThirtyTwoBytes payment_preimage_ref;
31012         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
31013         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
31014         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
31015         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
31016         return (int64_t)ret_conv;
31017 }
31018
31019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1probe(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray hops) {
31020         LDKChannelManager this_arg_conv;
31021         this_arg_conv.inner = (void*)(this_arg & (~1));
31022         this_arg_conv.is_owned = false;
31023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31024         LDKCVec_RouteHopZ hops_constr;
31025         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
31026         if (hops_constr.datalen > 0)
31027                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
31028         else
31029                 hops_constr.data = NULL;
31030         int64_t* hops_vals = (*env)->GetLongArrayElements (env, hops, NULL);
31031         for (size_t k = 0; k < hops_constr.datalen; k++) {
31032                 int64_t hops_conv_10 = hops_vals[k];
31033                 LDKRouteHop hops_conv_10_conv;
31034                 hops_conv_10_conv.inner = (void*)(hops_conv_10 & (~1));
31035                 hops_conv_10_conv.is_owned = (hops_conv_10 & 1) || (hops_conv_10 == 0);
31036                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv_10_conv);
31037                 hops_conv_10_conv = RouteHop_clone(&hops_conv_10_conv);
31038                 hops_constr.data[k] = hops_conv_10_conv;
31039         }
31040         (*env)->ReleaseLongArrayElements(env, hops, hops_vals, 0);
31041         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
31042         *ret_conv = ChannelManager_send_probe(&this_arg_conv, hops_constr);
31043         return (int64_t)ret_conv;
31044 }
31045
31046 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) {
31047         LDKChannelManager this_arg_conv;
31048         this_arg_conv.inner = (void*)(this_arg & (~1));
31049         this_arg_conv.is_owned = false;
31050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31051         unsigned char temporary_channel_id_arr[32];
31052         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
31053         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
31054         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
31055         LDKPublicKey counterparty_node_id_ref;
31056         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31057         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31058         LDKTransaction funding_transaction_ref;
31059         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
31060         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
31061         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
31062         funding_transaction_ref.data_is_owned = true;
31063         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31064         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
31065         return (int64_t)ret_conv;
31066 }
31067
31068 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) {
31069         LDKChannelManager this_arg_conv;
31070         this_arg_conv.inner = (void*)(this_arg & (~1));
31071         this_arg_conv.is_owned = false;
31072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31073         LDKThreeBytes rgb_ref;
31074         CHECK((*env)->GetArrayLength(env, rgb) == 3);
31075         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
31076         LDKThirtyTwoBytes alias_ref;
31077         CHECK((*env)->GetArrayLength(env, alias) == 32);
31078         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
31079         LDKCVec_NetAddressZ addresses_constr;
31080         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
31081         if (addresses_constr.datalen > 0)
31082                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
31083         else
31084                 addresses_constr.data = NULL;
31085         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
31086         for (size_t m = 0; m < addresses_constr.datalen; m++) {
31087                 int64_t addresses_conv_12 = addresses_vals[m];
31088                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
31089                 CHECK_ACCESS(addresses_conv_12_ptr);
31090                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
31091                 addresses_constr.data[m] = addresses_conv_12_conv;
31092         }
31093         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
31094         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
31095 }
31096
31097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1update_1channel_1config(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray counterparty_node_id, jobjectArray channel_ids, int64_t config) {
31098         LDKChannelManager this_arg_conv;
31099         this_arg_conv.inner = (void*)(this_arg & (~1));
31100         this_arg_conv.is_owned = false;
31101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31102         LDKPublicKey counterparty_node_id_ref;
31103         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31104         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31105         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
31106         channel_ids_constr.datalen = (*env)->GetArrayLength(env, channel_ids);
31107         if (channel_ids_constr.datalen > 0)
31108                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
31109         else
31110                 channel_ids_constr.data = NULL;
31111         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
31112                 int8_tArray channel_ids_conv_8 = (*env)->GetObjectArrayElement(env, channel_ids, i);
31113                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
31114                 CHECK((*env)->GetArrayLength(env, channel_ids_conv_8) == 32);
31115                 (*env)->GetByteArrayRegion(env, channel_ids_conv_8, 0, 32, channel_ids_conv_8_ref.data);
31116                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
31117         }
31118         LDKChannelConfig config_conv;
31119         config_conv.inner = (void*)(config & (~1));
31120         config_conv.is_owned = false;
31121         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
31122         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31123         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
31124         return (int64_t)ret_conv;
31125 }
31126
31127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
31128         LDKChannelManager this_arg_conv;
31129         this_arg_conv.inner = (void*)(this_arg & (~1));
31130         this_arg_conv.is_owned = false;
31131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31132         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
31133 }
31134
31135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
31136         LDKChannelManager this_arg_conv;
31137         this_arg_conv.inner = (void*)(this_arg & (~1));
31138         this_arg_conv.is_owned = false;
31139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31140         ChannelManager_timer_tick_occurred(&this_arg_conv);
31141 }
31142
31143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
31144         LDKChannelManager this_arg_conv;
31145         this_arg_conv.inner = (void*)(this_arg & (~1));
31146         this_arg_conv.is_owned = false;
31147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31148         unsigned char payment_hash_arr[32];
31149         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31150         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
31151         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
31152         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
31153 }
31154
31155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
31156         LDKChannelManager this_arg_conv;
31157         this_arg_conv.inner = (void*)(this_arg & (~1));
31158         this_arg_conv.is_owned = false;
31159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31160         LDKThirtyTwoBytes payment_preimage_ref;
31161         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
31162         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
31163         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
31164 }
31165
31166 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
31167         LDKChannelManager this_arg_conv;
31168         this_arg_conv.inner = (void*)(this_arg & (~1));
31169         this_arg_conv.is_owned = false;
31170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31171         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31172         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
31173         return ret_arr;
31174 }
31175
31176 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) {
31177         LDKChannelManager this_arg_conv;
31178         this_arg_conv.inner = (void*)(this_arg & (~1));
31179         this_arg_conv.is_owned = false;
31180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31181         unsigned char temporary_channel_id_arr[32];
31182         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
31183         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
31184         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
31185         LDKPublicKey counterparty_node_id_ref;
31186         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31187         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31188         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31189         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
31190         return (int64_t)ret_conv;
31191 }
31192
31193 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) {
31194         LDKChannelManager this_arg_conv;
31195         this_arg_conv.inner = (void*)(this_arg & (~1));
31196         this_arg_conv.is_owned = false;
31197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31198         unsigned char temporary_channel_id_arr[32];
31199         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
31200         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
31201         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
31202         LDKPublicKey counterparty_node_id_ref;
31203         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31204         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31205         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31206         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
31207         return (int64_t)ret_conv;
31208 }
31209
31210 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) {
31211         LDKChannelManager this_arg_conv;
31212         this_arg_conv.inner = (void*)(this_arg & (~1));
31213         this_arg_conv.is_owned = false;
31214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31215         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31216         CHECK_ACCESS(min_value_msat_ptr);
31217         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31218         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31219         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
31220         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
31221         return (int64_t)ret_conv;
31222 }
31223
31224 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) {
31225         LDKChannelManager this_arg_conv;
31226         this_arg_conv.inner = (void*)(this_arg & (~1));
31227         this_arg_conv.is_owned = false;
31228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31229         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31230         CHECK_ACCESS(min_value_msat_ptr);
31231         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31232         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31233         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
31234         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
31235         return (int64_t)ret_conv;
31236 }
31237
31238 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) {
31239         LDKChannelManager this_arg_conv;
31240         this_arg_conv.inner = (void*)(this_arg & (~1));
31241         this_arg_conv.is_owned = false;
31242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31243         LDKThirtyTwoBytes payment_hash_ref;
31244         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31245         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31246         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31247         CHECK_ACCESS(min_value_msat_ptr);
31248         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31249         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31250         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
31251         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
31252         return (int64_t)ret_conv;
31253 }
31254
31255 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) {
31256         LDKChannelManager this_arg_conv;
31257         this_arg_conv.inner = (void*)(this_arg & (~1));
31258         this_arg_conv.is_owned = false;
31259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31260         LDKThirtyTwoBytes payment_hash_ref;
31261         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31262         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31263         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31264         CHECK_ACCESS(min_value_msat_ptr);
31265         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31266         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31267         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
31268         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
31269         return (int64_t)ret_conv;
31270 }
31271
31272 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) {
31273         LDKChannelManager this_arg_conv;
31274         this_arg_conv.inner = (void*)(this_arg & (~1));
31275         this_arg_conv.is_owned = false;
31276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31277         LDKThirtyTwoBytes payment_hash_ref;
31278         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31279         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31280         LDKThirtyTwoBytes payment_secret_ref;
31281         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
31282         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
31283         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
31284         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
31285         return (int64_t)ret_conv;
31286 }
31287
31288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
31289         LDKChannelManager this_arg_conv;
31290         this_arg_conv.inner = (void*)(this_arg & (~1));
31291         this_arg_conv.is_owned = false;
31292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31293         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
31294         return ret_conv;
31295 }
31296
31297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
31298         LDKChannelManager this_arg_conv;
31299         this_arg_conv.inner = (void*)(this_arg & (~1));
31300         this_arg_conv.is_owned = false;
31301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31302         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
31303         int64_t ret_ref = 0;
31304         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31305         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31306         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31307         ret_ref = (uintptr_t)ret_var.inner;
31308         if (ret_var.is_owned) {
31309                 ret_ref |= 1;
31310         }
31311         return ret_ref;
31312 }
31313
31314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31315         LDKChannelManager this_arg_conv;
31316         this_arg_conv.inner = (void*)(this_arg & (~1));
31317         this_arg_conv.is_owned = false;
31318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31319         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
31320         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
31321         return (int64_t)ret_ret;
31322 }
31323
31324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31325         LDKChannelManager this_arg_conv;
31326         this_arg_conv.inner = (void*)(this_arg & (~1));
31327         this_arg_conv.is_owned = false;
31328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31329         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
31330         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
31331         return (int64_t)ret_ret;
31332 }
31333
31334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
31335         LDKChannelManager this_arg_conv;
31336         this_arg_conv.inner = (void*)(this_arg & (~1));
31337         this_arg_conv.is_owned = false;
31338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31339         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
31340         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
31341         return (int64_t)ret_ret;
31342 }
31343
31344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
31345         LDKChannelManager this_arg_conv;
31346         this_arg_conv.inner = (void*)(this_arg & (~1));
31347         this_arg_conv.is_owned = false;
31348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31349         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
31350         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
31351         return (int64_t)ret_ret;
31352 }
31353
31354 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) {
31355         LDKChannelManager this_arg_conv;
31356         this_arg_conv.inner = (void*)(this_arg & (~1));
31357         this_arg_conv.is_owned = false;
31358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31359         jboolean ret_conv = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
31360         return ret_conv;
31361 }
31362
31363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
31364         LDKChannelManager this_arg_conv;
31365         this_arg_conv.inner = (void*)(this_arg & (~1));
31366         this_arg_conv.is_owned = false;
31367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31368         ChannelManager_await_persistable_update(&this_arg_conv);
31369 }
31370
31371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
31372         LDKChannelManager this_arg_conv;
31373         this_arg_conv.inner = (void*)(this_arg & (~1));
31374         this_arg_conv.is_owned = false;
31375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31376         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
31377         int64_t ret_ref = 0;
31378         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31379         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31381         ret_ref = (uintptr_t)ret_var.inner;
31382         if (ret_var.is_owned) {
31383                 ret_ref |= 1;
31384         }
31385         return ret_ref;
31386 }
31387
31388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
31389         LDKChannelManager this_arg_conv;
31390         this_arg_conv.inner = (void*)(this_arg & (~1));
31391         this_arg_conv.is_owned = false;
31392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31393         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
31394         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
31395         return (int64_t)ret_ret;
31396 }
31397
31398 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
31399         LDKCounterpartyForwardingInfo obj_conv;
31400         obj_conv.inner = (void*)(obj & (~1));
31401         obj_conv.is_owned = false;
31402         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31403         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
31404         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31405         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31406         CVec_u8Z_free(ret_var);
31407         return ret_arr;
31408 }
31409
31410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31411         LDKu8slice ser_ref;
31412         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31413         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31414         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
31415         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
31416         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31417         return (int64_t)ret_conv;
31418 }
31419
31420 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
31421         LDKChannelCounterparty obj_conv;
31422         obj_conv.inner = (void*)(obj & (~1));
31423         obj_conv.is_owned = false;
31424         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31425         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
31426         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31427         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31428         CVec_u8Z_free(ret_var);
31429         return ret_arr;
31430 }
31431
31432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31433         LDKu8slice ser_ref;
31434         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31435         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31436         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
31437         *ret_conv = ChannelCounterparty_read(ser_ref);
31438         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31439         return (int64_t)ret_conv;
31440 }
31441
31442 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
31443         LDKChannelDetails obj_conv;
31444         obj_conv.inner = (void*)(obj & (~1));
31445         obj_conv.is_owned = false;
31446         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31447         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
31448         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31449         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31450         CVec_u8Z_free(ret_var);
31451         return ret_arr;
31452 }
31453
31454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31455         LDKu8slice ser_ref;
31456         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31457         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31458         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
31459         *ret_conv = ChannelDetails_read(ser_ref);
31460         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31461         return (int64_t)ret_conv;
31462 }
31463
31464 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
31465         LDKPhantomRouteHints obj_conv;
31466         obj_conv.inner = (void*)(obj & (~1));
31467         obj_conv.is_owned = false;
31468         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31469         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
31470         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31471         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31472         CVec_u8Z_free(ret_var);
31473         return ret_arr;
31474 }
31475
31476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31477         LDKu8slice ser_ref;
31478         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31479         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31480         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
31481         *ret_conv = PhantomRouteHints_read(ser_ref);
31482         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31483         return (int64_t)ret_conv;
31484 }
31485
31486 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
31487         LDKChannelManager obj_conv;
31488         obj_conv.inner = (void*)(obj & (~1));
31489         obj_conv.is_owned = false;
31490         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31491         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
31492         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31493         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31494         CVec_u8Z_free(ret_var);
31495         return ret_arr;
31496 }
31497
31498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31499         LDKChannelManagerReadArgs this_obj_conv;
31500         this_obj_conv.inner = (void*)(this_obj & (~1));
31501         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31503         ChannelManagerReadArgs_free(this_obj_conv);
31504 }
31505
31506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
31507         LDKChannelManagerReadArgs this_ptr_conv;
31508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31509         this_ptr_conv.is_owned = false;
31510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31511         // WARNING: This object doesn't live past this scope, needs clone!
31512         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
31513         return ret_ret;
31514 }
31515
31516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31517         LDKChannelManagerReadArgs this_ptr_conv;
31518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31519         this_ptr_conv.is_owned = false;
31520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31521         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31522         CHECK_ACCESS(val_ptr);
31523         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
31524         if (val_conv.free == LDKKeysInterface_JCalls_free) {
31525                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31526                 LDKKeysInterface_JCalls_cloned(&val_conv);
31527         }
31528         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
31529 }
31530
31531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
31532         LDKChannelManagerReadArgs this_ptr_conv;
31533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31534         this_ptr_conv.is_owned = false;
31535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31536         // WARNING: This object doesn't live past this scope, needs clone!
31537         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
31538         return ret_ret;
31539 }
31540
31541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31542         LDKChannelManagerReadArgs this_ptr_conv;
31543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31544         this_ptr_conv.is_owned = false;
31545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31546         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31547         CHECK_ACCESS(val_ptr);
31548         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
31549         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
31550                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31551                 LDKFeeEstimator_JCalls_cloned(&val_conv);
31552         }
31553         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
31554 }
31555
31556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
31557         LDKChannelManagerReadArgs this_ptr_conv;
31558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31559         this_ptr_conv.is_owned = false;
31560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31561         // WARNING: This object doesn't live past this scope, needs clone!
31562         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
31563         return ret_ret;
31564 }
31565
31566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31567         LDKChannelManagerReadArgs this_ptr_conv;
31568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31569         this_ptr_conv.is_owned = false;
31570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31571         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31572         CHECK_ACCESS(val_ptr);
31573         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
31574         if (val_conv.free == LDKWatch_JCalls_free) {
31575                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31576                 LDKWatch_JCalls_cloned(&val_conv);
31577         }
31578         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
31579 }
31580
31581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
31582         LDKChannelManagerReadArgs 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         // WARNING: This object doesn't live past this scope, needs clone!
31587         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
31588         return ret_ret;
31589 }
31590
31591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31592         LDKChannelManagerReadArgs 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         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31597         CHECK_ACCESS(val_ptr);
31598         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
31599         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
31600                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31601                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
31602         }
31603         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
31604 }
31605
31606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
31607         LDKChannelManagerReadArgs this_ptr_conv;
31608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31609         this_ptr_conv.is_owned = false;
31610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31611         // WARNING: This object doesn't live past this scope, needs clone!
31612         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
31613         return ret_ret;
31614 }
31615
31616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31617         LDKChannelManagerReadArgs this_ptr_conv;
31618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31619         this_ptr_conv.is_owned = false;
31620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31621         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31622         CHECK_ACCESS(val_ptr);
31623         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
31624         if (val_conv.free == LDKLogger_JCalls_free) {
31625                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31626                 LDKLogger_JCalls_cloned(&val_conv);
31627         }
31628         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
31629 }
31630
31631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
31632         LDKChannelManagerReadArgs this_ptr_conv;
31633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31634         this_ptr_conv.is_owned = false;
31635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31636         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
31637         int64_t ret_ref = 0;
31638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31641         ret_ref = (uintptr_t)ret_var.inner;
31642         if (ret_var.is_owned) {
31643                 ret_ref |= 1;
31644         }
31645         return ret_ref;
31646 }
31647
31648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31649         LDKChannelManagerReadArgs this_ptr_conv;
31650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31651         this_ptr_conv.is_owned = false;
31652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31653         LDKUserConfig val_conv;
31654         val_conv.inner = (void*)(val & (~1));
31655         val_conv.is_owned = (val & 1) || (val == 0);
31656         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31657         val_conv = UserConfig_clone(&val_conv);
31658         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
31659 }
31660
31661 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) {
31662         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
31663         CHECK_ACCESS(keys_manager_ptr);
31664         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
31665         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
31666                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31667                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
31668         }
31669         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
31670         CHECK_ACCESS(fee_estimator_ptr);
31671         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
31672         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
31673                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31674                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
31675         }
31676         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
31677         CHECK_ACCESS(chain_monitor_ptr);
31678         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
31679         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
31680                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31681                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
31682         }
31683         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
31684         CHECK_ACCESS(tx_broadcaster_ptr);
31685         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
31686         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
31687                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31688                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
31689         }
31690         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
31691         CHECK_ACCESS(logger_ptr);
31692         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
31693         if (logger_conv.free == LDKLogger_JCalls_free) {
31694                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31695                 LDKLogger_JCalls_cloned(&logger_conv);
31696         }
31697         LDKUserConfig default_config_conv;
31698         default_config_conv.inner = (void*)(default_config & (~1));
31699         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
31700         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
31701         default_config_conv = UserConfig_clone(&default_config_conv);
31702         LDKCVec_ChannelMonitorZ channel_monitors_constr;
31703         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
31704         if (channel_monitors_constr.datalen > 0)
31705                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
31706         else
31707                 channel_monitors_constr.data = NULL;
31708         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
31709         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
31710                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
31711                 LDKChannelMonitor channel_monitors_conv_16_conv;
31712                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
31713                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
31714                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
31715                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
31716         }
31717         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
31718         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);
31719         int64_t ret_ref = 0;
31720         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31721         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31722         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31723         ret_ref = (uintptr_t)ret_var.inner;
31724         if (ret_var.is_owned) {
31725                 ret_ref |= 1;
31726         }
31727         return ret_ref;
31728 }
31729
31730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
31731         LDKu8slice ser_ref;
31732         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31733         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31734         LDKChannelManagerReadArgs arg_conv;
31735         arg_conv.inner = (void*)(arg & (~1));
31736         arg_conv.is_owned = (arg & 1) || (arg == 0);
31737         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31738         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
31739         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
31740         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
31741         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31742         return (int64_t)ret_conv;
31743 }
31744
31745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31746         LDKExpandedKey this_obj_conv;
31747         this_obj_conv.inner = (void*)(this_obj & (~1));
31748         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31750         ExpandedKey_free(this_obj_conv);
31751 }
31752
31753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1new(JNIEnv *env, jclass clz, int8_tArray key_material) {
31754         unsigned char key_material_arr[32];
31755         CHECK((*env)->GetArrayLength(env, key_material) == 32);
31756         (*env)->GetByteArrayRegion(env, key_material, 0, 32, key_material_arr);
31757         unsigned char (*key_material_ref)[32] = &key_material_arr;
31758         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
31759         int64_t ret_ref = 0;
31760         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31761         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31763         ret_ref = (uintptr_t)ret_var.inner;
31764         if (ret_var.is_owned) {
31765                 ret_ref |= 1;
31766         }
31767         return ret_ref;
31768 }
31769
31770 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) {
31771         LDKExpandedKey keys_conv;
31772         keys_conv.inner = (void*)(keys & (~1));
31773         keys_conv.is_owned = false;
31774         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
31775         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31776         CHECK_ACCESS(min_value_msat_ptr);
31777         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31778         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31779         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
31780         if (!(keys_manager & 1)) { CHECK_ACCESS(keys_manager_ptr); }
31781         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
31782         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
31783         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
31784         return (int64_t)ret_conv;
31785 }
31786
31787 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) {
31788         LDKExpandedKey keys_conv;
31789         keys_conv.inner = (void*)(keys & (~1));
31790         keys_conv.is_owned = false;
31791         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
31792         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31793         CHECK_ACCESS(min_value_msat_ptr);
31794         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31795         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31796         LDKThirtyTwoBytes payment_hash_ref;
31797         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31798         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31799         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
31800         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
31801         return (int64_t)ret_conv;
31802 }
31803
31804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31805         LDKDecodeError this_obj_conv;
31806         this_obj_conv.inner = (void*)(this_obj & (~1));
31807         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31809         DecodeError_free(this_obj_conv);
31810 }
31811
31812 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
31813         LDKDecodeError ret_var = DecodeError_clone(arg);
31814 int64_t ret_ref = 0;
31815 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31816 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31817 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31818 ret_ref = (uintptr_t)ret_var.inner;
31819 if (ret_var.is_owned) {
31820         ret_ref |= 1;
31821 }
31822         return ret_ref;
31823 }
31824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31825         LDKDecodeError arg_conv;
31826         arg_conv.inner = (void*)(arg & (~1));
31827         arg_conv.is_owned = false;
31828         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31829         int64_t ret_conv = DecodeError_clone_ptr(&arg_conv);
31830         return ret_conv;
31831 }
31832
31833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31834         LDKDecodeError orig_conv;
31835         orig_conv.inner = (void*)(orig & (~1));
31836         orig_conv.is_owned = false;
31837         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31838         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
31839         int64_t ret_ref = 0;
31840         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31841         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31843         ret_ref = (uintptr_t)ret_var.inner;
31844         if (ret_var.is_owned) {
31845                 ret_ref |= 1;
31846         }
31847         return ret_ref;
31848 }
31849
31850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31851         LDKInit this_obj_conv;
31852         this_obj_conv.inner = (void*)(this_obj & (~1));
31853         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31855         Init_free(this_obj_conv);
31856 }
31857
31858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
31859         LDKInit 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         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
31864         int64_t ret_ref = 0;
31865         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31866         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31868         ret_ref = (uintptr_t)ret_var.inner;
31869         if (ret_var.is_owned) {
31870                 ret_ref |= 1;
31871         }
31872         return ret_ref;
31873 }
31874
31875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31876         LDKInit this_ptr_conv;
31877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31878         this_ptr_conv.is_owned = false;
31879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31880         LDKInitFeatures val_conv;
31881         val_conv.inner = (void*)(val & (~1));
31882         val_conv.is_owned = (val & 1) || (val == 0);
31883         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31884         val_conv = InitFeatures_clone(&val_conv);
31885         Init_set_features(&this_ptr_conv, val_conv);
31886 }
31887
31888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
31889         LDKInit this_ptr_conv;
31890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31891         this_ptr_conv.is_owned = false;
31892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31893         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
31894         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
31895         int64_t ret_ref = (uintptr_t)ret_copy;
31896         return ret_ref;
31897 }
31898
31899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31900         LDKInit this_ptr_conv;
31901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31902         this_ptr_conv.is_owned = false;
31903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31904         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31905         CHECK_ACCESS(val_ptr);
31906         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
31907         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
31908         Init_set_remote_network_address(&this_ptr_conv, val_conv);
31909 }
31910
31911 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) {
31912         LDKInitFeatures features_arg_conv;
31913         features_arg_conv.inner = (void*)(features_arg & (~1));
31914         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
31915         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
31916         features_arg_conv = InitFeatures_clone(&features_arg_conv);
31917         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
31918         CHECK_ACCESS(remote_network_address_arg_ptr);
31919         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
31920         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
31921         int64_t ret_ref = 0;
31922         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31923         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31925         ret_ref = (uintptr_t)ret_var.inner;
31926         if (ret_var.is_owned) {
31927                 ret_ref |= 1;
31928         }
31929         return ret_ref;
31930 }
31931
31932 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
31933         LDKInit ret_var = Init_clone(arg);
31934 int64_t ret_ref = 0;
31935 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31936 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31937 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31938 ret_ref = (uintptr_t)ret_var.inner;
31939 if (ret_var.is_owned) {
31940         ret_ref |= 1;
31941 }
31942         return ret_ref;
31943 }
31944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31945         LDKInit arg_conv;
31946         arg_conv.inner = (void*)(arg & (~1));
31947         arg_conv.is_owned = false;
31948         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31949         int64_t ret_conv = Init_clone_ptr(&arg_conv);
31950         return ret_conv;
31951 }
31952
31953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31954         LDKInit orig_conv;
31955         orig_conv.inner = (void*)(orig & (~1));
31956         orig_conv.is_owned = false;
31957         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31958         LDKInit ret_var = Init_clone(&orig_conv);
31959         int64_t ret_ref = 0;
31960         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31961         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31963         ret_ref = (uintptr_t)ret_var.inner;
31964         if (ret_var.is_owned) {
31965                 ret_ref |= 1;
31966         }
31967         return ret_ref;
31968 }
31969
31970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31971         LDKErrorMessage this_obj_conv;
31972         this_obj_conv.inner = (void*)(this_obj & (~1));
31973         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31975         ErrorMessage_free(this_obj_conv);
31976 }
31977
31978 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31979         LDKErrorMessage this_ptr_conv;
31980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31981         this_ptr_conv.is_owned = false;
31982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31983         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31984         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
31985         return ret_arr;
31986 }
31987
31988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31989         LDKErrorMessage this_ptr_conv;
31990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31991         this_ptr_conv.is_owned = false;
31992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31993         LDKThirtyTwoBytes val_ref;
31994         CHECK((*env)->GetArrayLength(env, val) == 32);
31995         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31996         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
31997 }
31998
31999 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
32000         LDKErrorMessage this_ptr_conv;
32001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32002         this_ptr_conv.is_owned = false;
32003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32004         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
32005         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
32006         Str_free(ret_str);
32007         return ret_conv;
32008 }
32009
32010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
32011         LDKErrorMessage this_ptr_conv;
32012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32013         this_ptr_conv.is_owned = false;
32014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32015         LDKStr val_conv = java_to_owned_str(env, val);
32016         ErrorMessage_set_data(&this_ptr_conv, val_conv);
32017 }
32018
32019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
32020         LDKThirtyTwoBytes channel_id_arg_ref;
32021         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32022         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32023         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
32024         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
32025         int64_t ret_ref = 0;
32026         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32027         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32029         ret_ref = (uintptr_t)ret_var.inner;
32030         if (ret_var.is_owned) {
32031                 ret_ref |= 1;
32032         }
32033         return ret_ref;
32034 }
32035
32036 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
32037         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
32038 int64_t ret_ref = 0;
32039 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32040 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32041 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32042 ret_ref = (uintptr_t)ret_var.inner;
32043 if (ret_var.is_owned) {
32044         ret_ref |= 1;
32045 }
32046         return ret_ref;
32047 }
32048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32049         LDKErrorMessage arg_conv;
32050         arg_conv.inner = (void*)(arg & (~1));
32051         arg_conv.is_owned = false;
32052         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32053         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
32054         return ret_conv;
32055 }
32056
32057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32058         LDKErrorMessage orig_conv;
32059         orig_conv.inner = (void*)(orig & (~1));
32060         orig_conv.is_owned = false;
32061         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32062         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
32063         int64_t ret_ref = 0;
32064         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32065         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32067         ret_ref = (uintptr_t)ret_var.inner;
32068         if (ret_var.is_owned) {
32069                 ret_ref |= 1;
32070         }
32071         return ret_ref;
32072 }
32073
32074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32075         LDKWarningMessage this_obj_conv;
32076         this_obj_conv.inner = (void*)(this_obj & (~1));
32077         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32079         WarningMessage_free(this_obj_conv);
32080 }
32081
32082 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32083         LDKWarningMessage this_ptr_conv;
32084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32085         this_ptr_conv.is_owned = false;
32086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32087         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32088         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
32089         return ret_arr;
32090 }
32091
32092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32093         LDKWarningMessage 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         LDKThirtyTwoBytes val_ref;
32098         CHECK((*env)->GetArrayLength(env, val) == 32);
32099         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32100         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
32101 }
32102
32103 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
32104         LDKWarningMessage this_ptr_conv;
32105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32106         this_ptr_conv.is_owned = false;
32107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32108         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
32109         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
32110         Str_free(ret_str);
32111         return ret_conv;
32112 }
32113
32114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
32115         LDKWarningMessage this_ptr_conv;
32116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32117         this_ptr_conv.is_owned = false;
32118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32119         LDKStr val_conv = java_to_owned_str(env, val);
32120         WarningMessage_set_data(&this_ptr_conv, val_conv);
32121 }
32122
32123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
32124         LDKThirtyTwoBytes channel_id_arg_ref;
32125         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32126         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32127         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
32128         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
32129         int64_t ret_ref = 0;
32130         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32131         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32133         ret_ref = (uintptr_t)ret_var.inner;
32134         if (ret_var.is_owned) {
32135                 ret_ref |= 1;
32136         }
32137         return ret_ref;
32138 }
32139
32140 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
32141         LDKWarningMessage ret_var = WarningMessage_clone(arg);
32142 int64_t ret_ref = 0;
32143 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32144 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32145 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32146 ret_ref = (uintptr_t)ret_var.inner;
32147 if (ret_var.is_owned) {
32148         ret_ref |= 1;
32149 }
32150         return ret_ref;
32151 }
32152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32153         LDKWarningMessage arg_conv;
32154         arg_conv.inner = (void*)(arg & (~1));
32155         arg_conv.is_owned = false;
32156         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32157         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
32158         return ret_conv;
32159 }
32160
32161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32162         LDKWarningMessage orig_conv;
32163         orig_conv.inner = (void*)(orig & (~1));
32164         orig_conv.is_owned = false;
32165         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32166         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
32167         int64_t ret_ref = 0;
32168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32171         ret_ref = (uintptr_t)ret_var.inner;
32172         if (ret_var.is_owned) {
32173                 ret_ref |= 1;
32174         }
32175         return ret_ref;
32176 }
32177
32178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32179         LDKPing this_obj_conv;
32180         this_obj_conv.inner = (void*)(this_obj & (~1));
32181         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32183         Ping_free(this_obj_conv);
32184 }
32185
32186 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
32187         LDKPing this_ptr_conv;
32188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32189         this_ptr_conv.is_owned = false;
32190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32191         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
32192         return ret_conv;
32193 }
32194
32195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32196         LDKPing this_ptr_conv;
32197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32198         this_ptr_conv.is_owned = false;
32199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32200         Ping_set_ponglen(&this_ptr_conv, val);
32201 }
32202
32203 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
32204         LDKPing this_ptr_conv;
32205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32206         this_ptr_conv.is_owned = false;
32207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32208         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
32209         return ret_conv;
32210 }
32211
32212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32213         LDKPing this_ptr_conv;
32214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32215         this_ptr_conv.is_owned = false;
32216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32217         Ping_set_byteslen(&this_ptr_conv, val);
32218 }
32219
32220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
32221         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
32222         int64_t ret_ref = 0;
32223         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32224         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32226         ret_ref = (uintptr_t)ret_var.inner;
32227         if (ret_var.is_owned) {
32228                 ret_ref |= 1;
32229         }
32230         return ret_ref;
32231 }
32232
32233 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
32234         LDKPing ret_var = Ping_clone(arg);
32235 int64_t ret_ref = 0;
32236 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32237 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32238 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32239 ret_ref = (uintptr_t)ret_var.inner;
32240 if (ret_var.is_owned) {
32241         ret_ref |= 1;
32242 }
32243         return ret_ref;
32244 }
32245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32246         LDKPing arg_conv;
32247         arg_conv.inner = (void*)(arg & (~1));
32248         arg_conv.is_owned = false;
32249         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32250         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
32251         return ret_conv;
32252 }
32253
32254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32255         LDKPing orig_conv;
32256         orig_conv.inner = (void*)(orig & (~1));
32257         orig_conv.is_owned = false;
32258         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32259         LDKPing ret_var = Ping_clone(&orig_conv);
32260         int64_t ret_ref = 0;
32261         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32262         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32264         ret_ref = (uintptr_t)ret_var.inner;
32265         if (ret_var.is_owned) {
32266                 ret_ref |= 1;
32267         }
32268         return ret_ref;
32269 }
32270
32271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32272         LDKPong this_obj_conv;
32273         this_obj_conv.inner = (void*)(this_obj & (~1));
32274         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32276         Pong_free(this_obj_conv);
32277 }
32278
32279 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
32280         LDKPong this_ptr_conv;
32281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32282         this_ptr_conv.is_owned = false;
32283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32284         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
32285         return ret_conv;
32286 }
32287
32288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32289         LDKPong this_ptr_conv;
32290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32291         this_ptr_conv.is_owned = false;
32292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32293         Pong_set_byteslen(&this_ptr_conv, val);
32294 }
32295
32296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
32297         LDKPong ret_var = Pong_new(byteslen_arg);
32298         int64_t ret_ref = 0;
32299         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32300         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32302         ret_ref = (uintptr_t)ret_var.inner;
32303         if (ret_var.is_owned) {
32304                 ret_ref |= 1;
32305         }
32306         return ret_ref;
32307 }
32308
32309 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
32310         LDKPong ret_var = Pong_clone(arg);
32311 int64_t ret_ref = 0;
32312 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32313 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32314 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32315 ret_ref = (uintptr_t)ret_var.inner;
32316 if (ret_var.is_owned) {
32317         ret_ref |= 1;
32318 }
32319         return ret_ref;
32320 }
32321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32322         LDKPong arg_conv;
32323         arg_conv.inner = (void*)(arg & (~1));
32324         arg_conv.is_owned = false;
32325         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32326         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
32327         return ret_conv;
32328 }
32329
32330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32331         LDKPong orig_conv;
32332         orig_conv.inner = (void*)(orig & (~1));
32333         orig_conv.is_owned = false;
32334         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32335         LDKPong ret_var = Pong_clone(&orig_conv);
32336         int64_t ret_ref = 0;
32337         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32338         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32339         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32340         ret_ref = (uintptr_t)ret_var.inner;
32341         if (ret_var.is_owned) {
32342                 ret_ref |= 1;
32343         }
32344         return ret_ref;
32345 }
32346
32347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32348         LDKOpenChannel this_obj_conv;
32349         this_obj_conv.inner = (void*)(this_obj & (~1));
32350         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32352         OpenChannel_free(this_obj_conv);
32353 }
32354
32355 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
32356         LDKOpenChannel this_ptr_conv;
32357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32358         this_ptr_conv.is_owned = false;
32359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32360         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32361         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
32362         return ret_arr;
32363 }
32364
32365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32366         LDKOpenChannel this_ptr_conv;
32367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32368         this_ptr_conv.is_owned = false;
32369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32370         LDKThirtyTwoBytes val_ref;
32371         CHECK((*env)->GetArrayLength(env, val) == 32);
32372         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32373         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
32374 }
32375
32376 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32377         LDKOpenChannel this_ptr_conv;
32378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32379         this_ptr_conv.is_owned = false;
32380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32381         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32382         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
32383         return ret_arr;
32384 }
32385
32386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32387         LDKOpenChannel this_ptr_conv;
32388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32389         this_ptr_conv.is_owned = false;
32390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32391         LDKThirtyTwoBytes val_ref;
32392         CHECK((*env)->GetArrayLength(env, val) == 32);
32393         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32394         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
32395 }
32396
32397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32398         LDKOpenChannel this_ptr_conv;
32399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32400         this_ptr_conv.is_owned = false;
32401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32402         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
32403         return ret_conv;
32404 }
32405
32406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32407         LDKOpenChannel this_ptr_conv;
32408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32409         this_ptr_conv.is_owned = false;
32410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32411         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
32412 }
32413
32414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32415         LDKOpenChannel this_ptr_conv;
32416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32417         this_ptr_conv.is_owned = false;
32418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32419         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
32420         return ret_conv;
32421 }
32422
32423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32424         LDKOpenChannel this_ptr_conv;
32425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32426         this_ptr_conv.is_owned = false;
32427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32428         OpenChannel_set_push_msat(&this_ptr_conv, val);
32429 }
32430
32431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32432         LDKOpenChannel this_ptr_conv;
32433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32434         this_ptr_conv.is_owned = false;
32435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32436         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
32437         return ret_conv;
32438 }
32439
32440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32441         LDKOpenChannel 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         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
32446 }
32447
32448 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) {
32449         LDKOpenChannel this_ptr_conv;
32450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32451         this_ptr_conv.is_owned = false;
32452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32453         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
32454         return ret_conv;
32455 }
32456
32457 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) {
32458         LDKOpenChannel this_ptr_conv;
32459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32460         this_ptr_conv.is_owned = false;
32461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32462         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
32463 }
32464
32465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32466         LDKOpenChannel this_ptr_conv;
32467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32468         this_ptr_conv.is_owned = false;
32469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32470         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
32471         return ret_conv;
32472 }
32473
32474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32475         LDKOpenChannel this_ptr_conv;
32476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32477         this_ptr_conv.is_owned = false;
32478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32479         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
32480 }
32481
32482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32483         LDKOpenChannel this_ptr_conv;
32484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32485         this_ptr_conv.is_owned = false;
32486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32487         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
32488         return ret_conv;
32489 }
32490
32491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32492         LDKOpenChannel this_ptr_conv;
32493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32494         this_ptr_conv.is_owned = false;
32495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32496         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
32497 }
32498
32499 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
32500         LDKOpenChannel this_ptr_conv;
32501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32502         this_ptr_conv.is_owned = false;
32503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32504         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
32505         return ret_conv;
32506 }
32507
32508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32509         LDKOpenChannel this_ptr_conv;
32510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32511         this_ptr_conv.is_owned = false;
32512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32513         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
32514 }
32515
32516 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32517         LDKOpenChannel this_ptr_conv;
32518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32519         this_ptr_conv.is_owned = false;
32520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32521         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
32522         return ret_conv;
32523 }
32524
32525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32526         LDKOpenChannel this_ptr_conv;
32527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32528         this_ptr_conv.is_owned = false;
32529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32530         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
32531 }
32532
32533 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
32534         LDKOpenChannel this_ptr_conv;
32535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32536         this_ptr_conv.is_owned = false;
32537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32538         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
32539         return ret_conv;
32540 }
32541
32542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32543         LDKOpenChannel this_ptr_conv;
32544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32545         this_ptr_conv.is_owned = false;
32546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32547         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
32548 }
32549
32550 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32551         LDKOpenChannel this_ptr_conv;
32552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32553         this_ptr_conv.is_owned = false;
32554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32555         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32556         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
32557         return ret_arr;
32558 }
32559
32560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32561         LDKOpenChannel this_ptr_conv;
32562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32563         this_ptr_conv.is_owned = false;
32564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32565         LDKPublicKey val_ref;
32566         CHECK((*env)->GetArrayLength(env, val) == 33);
32567         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32568         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
32569 }
32570
32571 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32572         LDKOpenChannel this_ptr_conv;
32573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32574         this_ptr_conv.is_owned = false;
32575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32576         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32577         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
32578         return ret_arr;
32579 }
32580
32581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32582         LDKOpenChannel this_ptr_conv;
32583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32584         this_ptr_conv.is_owned = false;
32585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32586         LDKPublicKey val_ref;
32587         CHECK((*env)->GetArrayLength(env, val) == 33);
32588         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32589         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
32590 }
32591
32592 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32593         LDKOpenChannel this_ptr_conv;
32594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32595         this_ptr_conv.is_owned = false;
32596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32597         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32598         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
32599         return ret_arr;
32600 }
32601
32602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32603         LDKOpenChannel this_ptr_conv;
32604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32605         this_ptr_conv.is_owned = false;
32606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32607         LDKPublicKey val_ref;
32608         CHECK((*env)->GetArrayLength(env, val) == 33);
32609         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32610         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
32611 }
32612
32613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32614         LDKOpenChannel this_ptr_conv;
32615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32616         this_ptr_conv.is_owned = false;
32617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32618         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32619         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
32620         return ret_arr;
32621 }
32622
32623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32624         LDKOpenChannel this_ptr_conv;
32625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32626         this_ptr_conv.is_owned = false;
32627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32628         LDKPublicKey val_ref;
32629         CHECK((*env)->GetArrayLength(env, val) == 33);
32630         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32631         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
32632 }
32633
32634 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32635         LDKOpenChannel this_ptr_conv;
32636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32637         this_ptr_conv.is_owned = false;
32638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32639         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32640         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
32641         return ret_arr;
32642 }
32643
32644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32645         LDKOpenChannel this_ptr_conv;
32646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32647         this_ptr_conv.is_owned = false;
32648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32649         LDKPublicKey val_ref;
32650         CHECK((*env)->GetArrayLength(env, val) == 33);
32651         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32652         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
32653 }
32654
32655 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32656         LDKOpenChannel this_ptr_conv;
32657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32658         this_ptr_conv.is_owned = false;
32659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32660         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32661         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
32662         return ret_arr;
32663 }
32664
32665 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) {
32666         LDKOpenChannel this_ptr_conv;
32667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32668         this_ptr_conv.is_owned = false;
32669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32670         LDKPublicKey val_ref;
32671         CHECK((*env)->GetArrayLength(env, val) == 33);
32672         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32673         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
32674 }
32675
32676 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
32677         LDKOpenChannel this_ptr_conv;
32678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32679         this_ptr_conv.is_owned = false;
32680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32681         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
32682         return ret_conv;
32683 }
32684
32685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
32686         LDKOpenChannel this_ptr_conv;
32687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32688         this_ptr_conv.is_owned = false;
32689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32690         OpenChannel_set_channel_flags(&this_ptr_conv, val);
32691 }
32692
32693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
32694         LDKOpenChannel this_ptr_conv;
32695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32696         this_ptr_conv.is_owned = false;
32697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32698         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
32699         int64_t ret_ref = 0;
32700         if ((uintptr_t)ret_var.inner > 4096) {
32701                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32702                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32704                 ret_ref = (uintptr_t)ret_var.inner;
32705                 if (ret_var.is_owned) {
32706                         ret_ref |= 1;
32707                 }
32708         }
32709         return ret_ref;
32710 }
32711
32712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32713         LDKOpenChannel this_ptr_conv;
32714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32715         this_ptr_conv.is_owned = false;
32716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32717         LDKChannelTypeFeatures val_conv;
32718         val_conv.inner = (void*)(val & (~1));
32719         val_conv.is_owned = (val & 1) || (val == 0);
32720         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32721         val_conv = ChannelTypeFeatures_clone(&val_conv);
32722         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
32723 }
32724
32725 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
32726         LDKOpenChannel ret_var = OpenChannel_clone(arg);
32727 int64_t ret_ref = 0;
32728 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32729 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32730 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32731 ret_ref = (uintptr_t)ret_var.inner;
32732 if (ret_var.is_owned) {
32733         ret_ref |= 1;
32734 }
32735         return ret_ref;
32736 }
32737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32738         LDKOpenChannel arg_conv;
32739         arg_conv.inner = (void*)(arg & (~1));
32740         arg_conv.is_owned = false;
32741         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32742         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
32743         return ret_conv;
32744 }
32745
32746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32747         LDKOpenChannel orig_conv;
32748         orig_conv.inner = (void*)(orig & (~1));
32749         orig_conv.is_owned = false;
32750         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32751         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
32752         int64_t ret_ref = 0;
32753         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32754         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32756         ret_ref = (uintptr_t)ret_var.inner;
32757         if (ret_var.is_owned) {
32758                 ret_ref |= 1;
32759         }
32760         return ret_ref;
32761 }
32762
32763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32764         LDKAcceptChannel this_obj_conv;
32765         this_obj_conv.inner = (void*)(this_obj & (~1));
32766         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32768         AcceptChannel_free(this_obj_conv);
32769 }
32770
32771 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32772         LDKAcceptChannel this_ptr_conv;
32773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32774         this_ptr_conv.is_owned = false;
32775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32776         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32777         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
32778         return ret_arr;
32779 }
32780
32781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32782         LDKAcceptChannel this_ptr_conv;
32783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32784         this_ptr_conv.is_owned = false;
32785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32786         LDKThirtyTwoBytes val_ref;
32787         CHECK((*env)->GetArrayLength(env, val) == 32);
32788         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32789         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
32790 }
32791
32792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32793         LDKAcceptChannel this_ptr_conv;
32794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32795         this_ptr_conv.is_owned = false;
32796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32797         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
32798         return ret_conv;
32799 }
32800
32801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32802         LDKAcceptChannel this_ptr_conv;
32803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32804         this_ptr_conv.is_owned = false;
32805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32806         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
32807 }
32808
32809 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) {
32810         LDKAcceptChannel this_ptr_conv;
32811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32812         this_ptr_conv.is_owned = false;
32813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32814         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
32815         return ret_conv;
32816 }
32817
32818 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) {
32819         LDKAcceptChannel this_ptr_conv;
32820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32821         this_ptr_conv.is_owned = false;
32822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32823         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
32824 }
32825
32826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32827         LDKAcceptChannel this_ptr_conv;
32828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32829         this_ptr_conv.is_owned = false;
32830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32831         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
32832         return ret_conv;
32833 }
32834
32835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32836         LDKAcceptChannel this_ptr_conv;
32837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32838         this_ptr_conv.is_owned = false;
32839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32840         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
32841 }
32842
32843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32844         LDKAcceptChannel this_ptr_conv;
32845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32846         this_ptr_conv.is_owned = false;
32847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32848         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
32849         return ret_conv;
32850 }
32851
32852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32853         LDKAcceptChannel this_ptr_conv;
32854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32855         this_ptr_conv.is_owned = false;
32856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32857         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
32858 }
32859
32860 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
32861         LDKAcceptChannel this_ptr_conv;
32862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32863         this_ptr_conv.is_owned = false;
32864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32865         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
32866         return ret_conv;
32867 }
32868
32869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32870         LDKAcceptChannel this_ptr_conv;
32871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32872         this_ptr_conv.is_owned = false;
32873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32874         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
32875 }
32876
32877 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32878         LDKAcceptChannel this_ptr_conv;
32879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32880         this_ptr_conv.is_owned = false;
32881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32882         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
32883         return ret_conv;
32884 }
32885
32886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32887         LDKAcceptChannel this_ptr_conv;
32888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32889         this_ptr_conv.is_owned = false;
32890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32891         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
32892 }
32893
32894 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
32895         LDKAcceptChannel this_ptr_conv;
32896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32897         this_ptr_conv.is_owned = false;
32898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32899         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
32900         return ret_conv;
32901 }
32902
32903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32904         LDKAcceptChannel this_ptr_conv;
32905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32906         this_ptr_conv.is_owned = false;
32907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32908         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
32909 }
32910
32911 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32912         LDKAcceptChannel this_ptr_conv;
32913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32914         this_ptr_conv.is_owned = false;
32915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32916         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32917         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
32918         return ret_arr;
32919 }
32920
32921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32922         LDKAcceptChannel this_ptr_conv;
32923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32924         this_ptr_conv.is_owned = false;
32925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32926         LDKPublicKey val_ref;
32927         CHECK((*env)->GetArrayLength(env, val) == 33);
32928         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32929         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
32930 }
32931
32932 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32933         LDKAcceptChannel this_ptr_conv;
32934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32935         this_ptr_conv.is_owned = false;
32936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32937         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32938         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
32939         return ret_arr;
32940 }
32941
32942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32943         LDKAcceptChannel this_ptr_conv;
32944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32945         this_ptr_conv.is_owned = false;
32946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32947         LDKPublicKey val_ref;
32948         CHECK((*env)->GetArrayLength(env, val) == 33);
32949         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32950         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
32951 }
32952
32953 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32954         LDKAcceptChannel this_ptr_conv;
32955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32956         this_ptr_conv.is_owned = false;
32957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32958         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32959         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
32960         return ret_arr;
32961 }
32962
32963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32964         LDKAcceptChannel 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         LDKPublicKey val_ref;
32969         CHECK((*env)->GetArrayLength(env, val) == 33);
32970         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32971         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
32972 }
32973
32974 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32975         LDKAcceptChannel this_ptr_conv;
32976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32977         this_ptr_conv.is_owned = false;
32978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32979         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32980         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
32981         return ret_arr;
32982 }
32983
32984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32985         LDKAcceptChannel this_ptr_conv;
32986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32987         this_ptr_conv.is_owned = false;
32988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32989         LDKPublicKey val_ref;
32990         CHECK((*env)->GetArrayLength(env, val) == 33);
32991         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32992         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
32993 }
32994
32995 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32996         LDKAcceptChannel this_ptr_conv;
32997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32998         this_ptr_conv.is_owned = false;
32999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33000         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33001         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
33002         return ret_arr;
33003 }
33004
33005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33006         LDKAcceptChannel this_ptr_conv;
33007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33008         this_ptr_conv.is_owned = false;
33009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33010         LDKPublicKey val_ref;
33011         CHECK((*env)->GetArrayLength(env, val) == 33);
33012         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33013         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
33014 }
33015
33016 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33017         LDKAcceptChannel this_ptr_conv;
33018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33019         this_ptr_conv.is_owned = false;
33020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33021         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33022         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
33023         return ret_arr;
33024 }
33025
33026 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) {
33027         LDKAcceptChannel this_ptr_conv;
33028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33029         this_ptr_conv.is_owned = false;
33030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33031         LDKPublicKey val_ref;
33032         CHECK((*env)->GetArrayLength(env, val) == 33);
33033         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33034         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
33035 }
33036
33037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
33038         LDKAcceptChannel this_ptr_conv;
33039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33040         this_ptr_conv.is_owned = false;
33041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33042         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
33043         int64_t ret_ref = 0;
33044         if ((uintptr_t)ret_var.inner > 4096) {
33045                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33046                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33048                 ret_ref = (uintptr_t)ret_var.inner;
33049                 if (ret_var.is_owned) {
33050                         ret_ref |= 1;
33051                 }
33052         }
33053         return ret_ref;
33054 }
33055
33056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33057         LDKAcceptChannel this_ptr_conv;
33058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33059         this_ptr_conv.is_owned = false;
33060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33061         LDKChannelTypeFeatures val_conv;
33062         val_conv.inner = (void*)(val & (~1));
33063         val_conv.is_owned = (val & 1) || (val == 0);
33064         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33065         val_conv = ChannelTypeFeatures_clone(&val_conv);
33066         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
33067 }
33068
33069 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
33070         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
33071 int64_t ret_ref = 0;
33072 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33073 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33074 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33075 ret_ref = (uintptr_t)ret_var.inner;
33076 if (ret_var.is_owned) {
33077         ret_ref |= 1;
33078 }
33079         return ret_ref;
33080 }
33081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33082         LDKAcceptChannel arg_conv;
33083         arg_conv.inner = (void*)(arg & (~1));
33084         arg_conv.is_owned = false;
33085         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33086         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
33087         return ret_conv;
33088 }
33089
33090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33091         LDKAcceptChannel orig_conv;
33092         orig_conv.inner = (void*)(orig & (~1));
33093         orig_conv.is_owned = false;
33094         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33095         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
33096         int64_t ret_ref = 0;
33097         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33098         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33100         ret_ref = (uintptr_t)ret_var.inner;
33101         if (ret_var.is_owned) {
33102                 ret_ref |= 1;
33103         }
33104         return ret_ref;
33105 }
33106
33107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33108         LDKFundingCreated this_obj_conv;
33109         this_obj_conv.inner = (void*)(this_obj & (~1));
33110         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33112         FundingCreated_free(this_obj_conv);
33113 }
33114
33115 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33116         LDKFundingCreated this_ptr_conv;
33117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33118         this_ptr_conv.is_owned = false;
33119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33120         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33121         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
33122         return ret_arr;
33123 }
33124
33125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33126         LDKFundingCreated this_ptr_conv;
33127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33128         this_ptr_conv.is_owned = false;
33129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33130         LDKThirtyTwoBytes val_ref;
33131         CHECK((*env)->GetArrayLength(env, val) == 32);
33132         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33133         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
33134 }
33135
33136 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
33137         LDKFundingCreated this_ptr_conv;
33138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33139         this_ptr_conv.is_owned = false;
33140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33141         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33142         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
33143         return ret_arr;
33144 }
33145
33146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33147         LDKFundingCreated this_ptr_conv;
33148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33149         this_ptr_conv.is_owned = false;
33150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33151         LDKThirtyTwoBytes val_ref;
33152         CHECK((*env)->GetArrayLength(env, val) == 32);
33153         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33154         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
33155 }
33156
33157 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
33158         LDKFundingCreated this_ptr_conv;
33159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33160         this_ptr_conv.is_owned = false;
33161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33162         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
33163         return ret_conv;
33164 }
33165
33166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33167         LDKFundingCreated this_ptr_conv;
33168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33169         this_ptr_conv.is_owned = false;
33170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33171         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
33172 }
33173
33174 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33175         LDKFundingCreated this_ptr_conv;
33176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33177         this_ptr_conv.is_owned = false;
33178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33179         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33180         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
33181         return ret_arr;
33182 }
33183
33184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33185         LDKFundingCreated this_ptr_conv;
33186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33187         this_ptr_conv.is_owned = false;
33188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33189         LDKSignature val_ref;
33190         CHECK((*env)->GetArrayLength(env, val) == 64);
33191         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33192         FundingCreated_set_signature(&this_ptr_conv, val_ref);
33193 }
33194
33195 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) {
33196         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
33197         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
33198         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
33199         LDKThirtyTwoBytes funding_txid_arg_ref;
33200         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
33201         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
33202         LDKSignature signature_arg_ref;
33203         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33204         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33205         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
33206         int64_t ret_ref = 0;
33207         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33208         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33210         ret_ref = (uintptr_t)ret_var.inner;
33211         if (ret_var.is_owned) {
33212                 ret_ref |= 1;
33213         }
33214         return ret_ref;
33215 }
33216
33217 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
33218         LDKFundingCreated ret_var = FundingCreated_clone(arg);
33219 int64_t ret_ref = 0;
33220 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33221 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33222 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33223 ret_ref = (uintptr_t)ret_var.inner;
33224 if (ret_var.is_owned) {
33225         ret_ref |= 1;
33226 }
33227         return ret_ref;
33228 }
33229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33230         LDKFundingCreated arg_conv;
33231         arg_conv.inner = (void*)(arg & (~1));
33232         arg_conv.is_owned = false;
33233         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33234         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
33235         return ret_conv;
33236 }
33237
33238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33239         LDKFundingCreated orig_conv;
33240         orig_conv.inner = (void*)(orig & (~1));
33241         orig_conv.is_owned = false;
33242         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33243         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
33244         int64_t ret_ref = 0;
33245         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33246         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33248         ret_ref = (uintptr_t)ret_var.inner;
33249         if (ret_var.is_owned) {
33250                 ret_ref |= 1;
33251         }
33252         return ret_ref;
33253 }
33254
33255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33256         LDKFundingSigned this_obj_conv;
33257         this_obj_conv.inner = (void*)(this_obj & (~1));
33258         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33260         FundingSigned_free(this_obj_conv);
33261 }
33262
33263 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33264         LDKFundingSigned 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, 32);
33269         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
33270         return ret_arr;
33271 }
33272
33273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33274         LDKFundingSigned 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         LDKThirtyTwoBytes val_ref;
33279         CHECK((*env)->GetArrayLength(env, val) == 32);
33280         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33281         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
33282 }
33283
33284 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33285         LDKFundingSigned 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33290         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
33291         return ret_arr;
33292 }
33293
33294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33295         LDKFundingSigned this_ptr_conv;
33296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33297         this_ptr_conv.is_owned = false;
33298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33299         LDKSignature val_ref;
33300         CHECK((*env)->GetArrayLength(env, val) == 64);
33301         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33302         FundingSigned_set_signature(&this_ptr_conv, val_ref);
33303 }
33304
33305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_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         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
33313         int64_t ret_ref = 0;
33314         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33315         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33317         ret_ref = (uintptr_t)ret_var.inner;
33318         if (ret_var.is_owned) {
33319                 ret_ref |= 1;
33320         }
33321         return ret_ref;
33322 }
33323
33324 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
33325         LDKFundingSigned ret_var = FundingSigned_clone(arg);
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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33337         LDKFundingSigned arg_conv;
33338         arg_conv.inner = (void*)(arg & (~1));
33339         arg_conv.is_owned = false;
33340         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33341         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
33342         return ret_conv;
33343 }
33344
33345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33346         LDKFundingSigned orig_conv;
33347         orig_conv.inner = (void*)(orig & (~1));
33348         orig_conv.is_owned = false;
33349         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33350         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
33351         int64_t ret_ref = 0;
33352         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33353         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33355         ret_ref = (uintptr_t)ret_var.inner;
33356         if (ret_var.is_owned) {
33357                 ret_ref |= 1;
33358         }
33359         return ret_ref;
33360 }
33361
33362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33363         LDKChannelReady this_obj_conv;
33364         this_obj_conv.inner = (void*)(this_obj & (~1));
33365         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33367         ChannelReady_free(this_obj_conv);
33368 }
33369
33370 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33371         LDKChannelReady this_ptr_conv;
33372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33373         this_ptr_conv.is_owned = false;
33374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33375         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33376         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReady_get_channel_id(&this_ptr_conv));
33377         return ret_arr;
33378 }
33379
33380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33381         LDKChannelReady this_ptr_conv;
33382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33383         this_ptr_conv.is_owned = false;
33384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33385         LDKThirtyTwoBytes val_ref;
33386         CHECK((*env)->GetArrayLength(env, val) == 32);
33387         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33388         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
33389 }
33390
33391 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33392         LDKChannelReady this_ptr_conv;
33393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33394         this_ptr_conv.is_owned = false;
33395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33396         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33397         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
33398         return ret_arr;
33399 }
33400
33401 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) {
33402         LDKChannelReady this_ptr_conv;
33403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33404         this_ptr_conv.is_owned = false;
33405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33406         LDKPublicKey val_ref;
33407         CHECK((*env)->GetArrayLength(env, val) == 33);
33408         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33409         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
33410 }
33411
33412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
33413         LDKChannelReady this_ptr_conv;
33414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33415         this_ptr_conv.is_owned = false;
33416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33417         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
33418         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
33419         int64_t ret_ref = (uintptr_t)ret_copy;
33420         return ret_ref;
33421 }
33422
33423 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) {
33424         LDKChannelReady this_ptr_conv;
33425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33426         this_ptr_conv.is_owned = false;
33427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33428         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33429         CHECK_ACCESS(val_ptr);
33430         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
33431         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
33432         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
33433 }
33434
33435 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) {
33436         LDKThirtyTwoBytes channel_id_arg_ref;
33437         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33438         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33439         LDKPublicKey next_per_commitment_point_arg_ref;
33440         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
33441         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
33442         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
33443         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
33444         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
33445         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
33446         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
33447         int64_t ret_ref = 0;
33448         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33449         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33451         ret_ref = (uintptr_t)ret_var.inner;
33452         if (ret_var.is_owned) {
33453                 ret_ref |= 1;
33454         }
33455         return ret_ref;
33456 }
33457
33458 static inline uintptr_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
33459         LDKChannelReady ret_var = ChannelReady_clone(arg);
33460 int64_t ret_ref = 0;
33461 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33462 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33463 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33464 ret_ref = (uintptr_t)ret_var.inner;
33465 if (ret_var.is_owned) {
33466         ret_ref |= 1;
33467 }
33468         return ret_ref;
33469 }
33470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33471         LDKChannelReady arg_conv;
33472         arg_conv.inner = (void*)(arg & (~1));
33473         arg_conv.is_owned = false;
33474         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33475         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
33476         return ret_conv;
33477 }
33478
33479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33480         LDKChannelReady orig_conv;
33481         orig_conv.inner = (void*)(orig & (~1));
33482         orig_conv.is_owned = false;
33483         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33484         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
33485         int64_t ret_ref = 0;
33486         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33487         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33488         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33489         ret_ref = (uintptr_t)ret_var.inner;
33490         if (ret_var.is_owned) {
33491                 ret_ref |= 1;
33492         }
33493         return ret_ref;
33494 }
33495
33496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33497         LDKShutdown this_obj_conv;
33498         this_obj_conv.inner = (void*)(this_obj & (~1));
33499         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33501         Shutdown_free(this_obj_conv);
33502 }
33503
33504 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33505         LDKShutdown this_ptr_conv;
33506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33507         this_ptr_conv.is_owned = false;
33508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33509         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33510         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
33511         return ret_arr;
33512 }
33513
33514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33515         LDKShutdown 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         LDKThirtyTwoBytes val_ref;
33520         CHECK((*env)->GetArrayLength(env, val) == 32);
33521         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33522         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
33523 }
33524
33525 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
33526         LDKShutdown this_ptr_conv;
33527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33528         this_ptr_conv.is_owned = false;
33529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33530         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
33531         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33532         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33533         return ret_arr;
33534 }
33535
33536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33537         LDKShutdown this_ptr_conv;
33538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33539         this_ptr_conv.is_owned = false;
33540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33541         LDKCVec_u8Z val_ref;
33542         val_ref.datalen = (*env)->GetArrayLength(env, val);
33543         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
33544         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
33545         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
33546 }
33547
33548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
33549         LDKThirtyTwoBytes channel_id_arg_ref;
33550         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33551         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33552         LDKCVec_u8Z scriptpubkey_arg_ref;
33553         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
33554         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
33555         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
33556         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
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 Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
33569         LDKShutdown ret_var = Shutdown_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_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33581         LDKShutdown 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 = Shutdown_clone_ptr(&arg_conv);
33586         return ret_conv;
33587 }
33588
33589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33590         LDKShutdown 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         LDKShutdown ret_var = Shutdown_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_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33607         LDKClosingSignedFeeRange 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         ClosingSignedFeeRange_free(this_obj_conv);
33612 }
33613
33614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33615         LDKClosingSignedFeeRange 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         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
33620         return ret_conv;
33621 }
33622
33623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33624         LDKClosingSignedFeeRange this_ptr_conv;
33625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33626         this_ptr_conv.is_owned = false;
33627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33628         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
33629 }
33630
33631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33632         LDKClosingSignedFeeRange this_ptr_conv;
33633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33634         this_ptr_conv.is_owned = false;
33635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33636         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
33637         return ret_conv;
33638 }
33639
33640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33641         LDKClosingSignedFeeRange this_ptr_conv;
33642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33643         this_ptr_conv.is_owned = false;
33644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33645         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
33646 }
33647
33648 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) {
33649         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
33650         int64_t ret_ref = 0;
33651         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33652         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33654         ret_ref = (uintptr_t)ret_var.inner;
33655         if (ret_var.is_owned) {
33656                 ret_ref |= 1;
33657         }
33658         return ret_ref;
33659 }
33660
33661 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
33662         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
33663 int64_t ret_ref = 0;
33664 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33665 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33666 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33667 ret_ref = (uintptr_t)ret_var.inner;
33668 if (ret_var.is_owned) {
33669         ret_ref |= 1;
33670 }
33671         return ret_ref;
33672 }
33673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33674         LDKClosingSignedFeeRange arg_conv;
33675         arg_conv.inner = (void*)(arg & (~1));
33676         arg_conv.is_owned = false;
33677         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33678         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
33679         return ret_conv;
33680 }
33681
33682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33683         LDKClosingSignedFeeRange orig_conv;
33684         orig_conv.inner = (void*)(orig & (~1));
33685         orig_conv.is_owned = false;
33686         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33687         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
33688         int64_t ret_ref = 0;
33689         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33690         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33692         ret_ref = (uintptr_t)ret_var.inner;
33693         if (ret_var.is_owned) {
33694                 ret_ref |= 1;
33695         }
33696         return ret_ref;
33697 }
33698
33699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33700         LDKClosingSigned this_obj_conv;
33701         this_obj_conv.inner = (void*)(this_obj & (~1));
33702         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33704         ClosingSigned_free(this_obj_conv);
33705 }
33706
33707 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33708         LDKClosingSigned this_ptr_conv;
33709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33710         this_ptr_conv.is_owned = false;
33711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33712         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33713         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
33714         return ret_arr;
33715 }
33716
33717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33718         LDKClosingSigned this_ptr_conv;
33719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33720         this_ptr_conv.is_owned = false;
33721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33722         LDKThirtyTwoBytes val_ref;
33723         CHECK((*env)->GetArrayLength(env, val) == 32);
33724         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33725         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
33726 }
33727
33728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33729         LDKClosingSigned this_ptr_conv;
33730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33731         this_ptr_conv.is_owned = false;
33732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33733         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
33734         return ret_conv;
33735 }
33736
33737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33738         LDKClosingSigned this_ptr_conv;
33739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33740         this_ptr_conv.is_owned = false;
33741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33742         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
33743 }
33744
33745 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33746         LDKClosingSigned this_ptr_conv;
33747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33748         this_ptr_conv.is_owned = false;
33749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33750         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33751         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
33752         return ret_arr;
33753 }
33754
33755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33756         LDKClosingSigned this_ptr_conv;
33757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33758         this_ptr_conv.is_owned = false;
33759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33760         LDKSignature val_ref;
33761         CHECK((*env)->GetArrayLength(env, val) == 64);
33762         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33763         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
33764 }
33765
33766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
33767         LDKClosingSigned this_ptr_conv;
33768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33769         this_ptr_conv.is_owned = false;
33770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33771         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
33772         int64_t ret_ref = 0;
33773         if ((uintptr_t)ret_var.inner > 4096) {
33774                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33775                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33777                 ret_ref = (uintptr_t)ret_var.inner;
33778                 if (ret_var.is_owned) {
33779                         ret_ref |= 1;
33780                 }
33781         }
33782         return ret_ref;
33783 }
33784
33785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33786         LDKClosingSigned this_ptr_conv;
33787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33788         this_ptr_conv.is_owned = false;
33789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33790         LDKClosingSignedFeeRange val_conv;
33791         val_conv.inner = (void*)(val & (~1));
33792         val_conv.is_owned = (val & 1) || (val == 0);
33793         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33794         val_conv = ClosingSignedFeeRange_clone(&val_conv);
33795         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
33796 }
33797
33798 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) {
33799         LDKThirtyTwoBytes channel_id_arg_ref;
33800         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33801         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33802         LDKSignature signature_arg_ref;
33803         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33804         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33805         LDKClosingSignedFeeRange fee_range_arg_conv;
33806         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
33807         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
33808         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
33809         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
33810         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
33811         int64_t ret_ref = 0;
33812         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33813         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33814         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33815         ret_ref = (uintptr_t)ret_var.inner;
33816         if (ret_var.is_owned) {
33817                 ret_ref |= 1;
33818         }
33819         return ret_ref;
33820 }
33821
33822 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
33823         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
33824 int64_t ret_ref = 0;
33825 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33826 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33827 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33828 ret_ref = (uintptr_t)ret_var.inner;
33829 if (ret_var.is_owned) {
33830         ret_ref |= 1;
33831 }
33832         return ret_ref;
33833 }
33834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33835         LDKClosingSigned arg_conv;
33836         arg_conv.inner = (void*)(arg & (~1));
33837         arg_conv.is_owned = false;
33838         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33839         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
33840         return ret_conv;
33841 }
33842
33843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33844         LDKClosingSigned orig_conv;
33845         orig_conv.inner = (void*)(orig & (~1));
33846         orig_conv.is_owned = false;
33847         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33848         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
33849         int64_t ret_ref = 0;
33850         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33851         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33852         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33853         ret_ref = (uintptr_t)ret_var.inner;
33854         if (ret_var.is_owned) {
33855                 ret_ref |= 1;
33856         }
33857         return ret_ref;
33858 }
33859
33860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33861         LDKUpdateAddHTLC this_obj_conv;
33862         this_obj_conv.inner = (void*)(this_obj & (~1));
33863         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33865         UpdateAddHTLC_free(this_obj_conv);
33866 }
33867
33868 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33869         LDKUpdateAddHTLC this_ptr_conv;
33870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33871         this_ptr_conv.is_owned = false;
33872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33873         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33874         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
33875         return ret_arr;
33876 }
33877
33878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33879         LDKUpdateAddHTLC this_ptr_conv;
33880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33881         this_ptr_conv.is_owned = false;
33882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33883         LDKThirtyTwoBytes val_ref;
33884         CHECK((*env)->GetArrayLength(env, val) == 32);
33885         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33886         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
33887 }
33888
33889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33890         LDKUpdateAddHTLC this_ptr_conv;
33891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33892         this_ptr_conv.is_owned = false;
33893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33894         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
33895         return ret_conv;
33896 }
33897
33898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33899         LDKUpdateAddHTLC this_ptr_conv;
33900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33901         this_ptr_conv.is_owned = false;
33902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33903         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
33904 }
33905
33906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33907         LDKUpdateAddHTLC this_ptr_conv;
33908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33909         this_ptr_conv.is_owned = false;
33910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33911         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
33912         return ret_conv;
33913 }
33914
33915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33916         LDKUpdateAddHTLC this_ptr_conv;
33917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33918         this_ptr_conv.is_owned = false;
33919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33920         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
33921 }
33922
33923 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33924         LDKUpdateAddHTLC this_ptr_conv;
33925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33926         this_ptr_conv.is_owned = false;
33927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33928         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33929         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
33930         return ret_arr;
33931 }
33932
33933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33934         LDKUpdateAddHTLC this_ptr_conv;
33935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33936         this_ptr_conv.is_owned = false;
33937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33938         LDKThirtyTwoBytes val_ref;
33939         CHECK((*env)->GetArrayLength(env, val) == 32);
33940         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33941         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
33942 }
33943
33944 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
33945         LDKUpdateAddHTLC this_ptr_conv;
33946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33947         this_ptr_conv.is_owned = false;
33948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33949         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
33950         return ret_conv;
33951 }
33952
33953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33954         LDKUpdateAddHTLC this_ptr_conv;
33955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33956         this_ptr_conv.is_owned = false;
33957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33958         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
33959 }
33960
33961 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
33962         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
33963 int64_t ret_ref = 0;
33964 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33965 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33966 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33967 ret_ref = (uintptr_t)ret_var.inner;
33968 if (ret_var.is_owned) {
33969         ret_ref |= 1;
33970 }
33971         return ret_ref;
33972 }
33973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33974         LDKUpdateAddHTLC arg_conv;
33975         arg_conv.inner = (void*)(arg & (~1));
33976         arg_conv.is_owned = false;
33977         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33978         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
33979         return ret_conv;
33980 }
33981
33982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33983         LDKUpdateAddHTLC orig_conv;
33984         orig_conv.inner = (void*)(orig & (~1));
33985         orig_conv.is_owned = false;
33986         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33987         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
33988         int64_t ret_ref = 0;
33989         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33990         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33991         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33992         ret_ref = (uintptr_t)ret_var.inner;
33993         if (ret_var.is_owned) {
33994                 ret_ref |= 1;
33995         }
33996         return ret_ref;
33997 }
33998
33999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34000         LDKUpdateFulfillHTLC this_obj_conv;
34001         this_obj_conv.inner = (void*)(this_obj & (~1));
34002         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34004         UpdateFulfillHTLC_free(this_obj_conv);
34005 }
34006
34007 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34008         LDKUpdateFulfillHTLC this_ptr_conv;
34009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34010         this_ptr_conv.is_owned = false;
34011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34012         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34013         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
34014         return ret_arr;
34015 }
34016
34017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34018         LDKUpdateFulfillHTLC this_ptr_conv;
34019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34020         this_ptr_conv.is_owned = false;
34021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34022         LDKThirtyTwoBytes val_ref;
34023         CHECK((*env)->GetArrayLength(env, val) == 32);
34024         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34025         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
34026 }
34027
34028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34029         LDKUpdateFulfillHTLC this_ptr_conv;
34030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34031         this_ptr_conv.is_owned = false;
34032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34033         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
34034         return ret_conv;
34035 }
34036
34037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34038         LDKUpdateFulfillHTLC this_ptr_conv;
34039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34040         this_ptr_conv.is_owned = false;
34041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34042         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
34043 }
34044
34045 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
34046         LDKUpdateFulfillHTLC this_ptr_conv;
34047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34048         this_ptr_conv.is_owned = false;
34049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34050         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34051         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
34052         return ret_arr;
34053 }
34054
34055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34056         LDKUpdateFulfillHTLC this_ptr_conv;
34057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34058         this_ptr_conv.is_owned = false;
34059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34060         LDKThirtyTwoBytes val_ref;
34061         CHECK((*env)->GetArrayLength(env, val) == 32);
34062         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34063         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
34064 }
34065
34066 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) {
34067         LDKThirtyTwoBytes channel_id_arg_ref;
34068         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34069         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34070         LDKThirtyTwoBytes payment_preimage_arg_ref;
34071         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
34072         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
34073         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
34074         int64_t ret_ref = 0;
34075         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34076         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34078         ret_ref = (uintptr_t)ret_var.inner;
34079         if (ret_var.is_owned) {
34080                 ret_ref |= 1;
34081         }
34082         return ret_ref;
34083 }
34084
34085 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
34086         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
34087 int64_t ret_ref = 0;
34088 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34089 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34090 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34091 ret_ref = (uintptr_t)ret_var.inner;
34092 if (ret_var.is_owned) {
34093         ret_ref |= 1;
34094 }
34095         return ret_ref;
34096 }
34097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34098         LDKUpdateFulfillHTLC arg_conv;
34099         arg_conv.inner = (void*)(arg & (~1));
34100         arg_conv.is_owned = false;
34101         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34102         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
34103         return ret_conv;
34104 }
34105
34106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34107         LDKUpdateFulfillHTLC orig_conv;
34108         orig_conv.inner = (void*)(orig & (~1));
34109         orig_conv.is_owned = false;
34110         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34111         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
34112         int64_t ret_ref = 0;
34113         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34114         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34116         ret_ref = (uintptr_t)ret_var.inner;
34117         if (ret_var.is_owned) {
34118                 ret_ref |= 1;
34119         }
34120         return ret_ref;
34121 }
34122
34123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34124         LDKUpdateFailHTLC this_obj_conv;
34125         this_obj_conv.inner = (void*)(this_obj & (~1));
34126         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34128         UpdateFailHTLC_free(this_obj_conv);
34129 }
34130
34131 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34132         LDKUpdateFailHTLC this_ptr_conv;
34133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34134         this_ptr_conv.is_owned = false;
34135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34136         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34137         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
34138         return ret_arr;
34139 }
34140
34141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34142         LDKUpdateFailHTLC this_ptr_conv;
34143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34144         this_ptr_conv.is_owned = false;
34145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34146         LDKThirtyTwoBytes val_ref;
34147         CHECK((*env)->GetArrayLength(env, val) == 32);
34148         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34149         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
34150 }
34151
34152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34153         LDKUpdateFailHTLC this_ptr_conv;
34154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34155         this_ptr_conv.is_owned = false;
34156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34157         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
34158         return ret_conv;
34159 }
34160
34161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34162         LDKUpdateFailHTLC this_ptr_conv;
34163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34164         this_ptr_conv.is_owned = false;
34165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34166         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
34167 }
34168
34169 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
34170         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
34171 int64_t ret_ref = 0;
34172 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34173 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34174 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34175 ret_ref = (uintptr_t)ret_var.inner;
34176 if (ret_var.is_owned) {
34177         ret_ref |= 1;
34178 }
34179         return ret_ref;
34180 }
34181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34182         LDKUpdateFailHTLC arg_conv;
34183         arg_conv.inner = (void*)(arg & (~1));
34184         arg_conv.is_owned = false;
34185         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34186         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
34187         return ret_conv;
34188 }
34189
34190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34191         LDKUpdateFailHTLC orig_conv;
34192         orig_conv.inner = (void*)(orig & (~1));
34193         orig_conv.is_owned = false;
34194         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34195         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
34196         int64_t ret_ref = 0;
34197         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34198         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34200         ret_ref = (uintptr_t)ret_var.inner;
34201         if (ret_var.is_owned) {
34202                 ret_ref |= 1;
34203         }
34204         return ret_ref;
34205 }
34206
34207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34208         LDKUpdateFailMalformedHTLC this_obj_conv;
34209         this_obj_conv.inner = (void*)(this_obj & (~1));
34210         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34212         UpdateFailMalformedHTLC_free(this_obj_conv);
34213 }
34214
34215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34216         LDKUpdateFailMalformedHTLC this_ptr_conv;
34217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34218         this_ptr_conv.is_owned = false;
34219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34220         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34221         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
34222         return ret_arr;
34223 }
34224
34225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34226         LDKUpdateFailMalformedHTLC this_ptr_conv;
34227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34228         this_ptr_conv.is_owned = false;
34229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34230         LDKThirtyTwoBytes val_ref;
34231         CHECK((*env)->GetArrayLength(env, val) == 32);
34232         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34233         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
34234 }
34235
34236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34237         LDKUpdateFailMalformedHTLC this_ptr_conv;
34238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34239         this_ptr_conv.is_owned = false;
34240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34241         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
34242         return ret_conv;
34243 }
34244
34245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34246         LDKUpdateFailMalformedHTLC this_ptr_conv;
34247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34248         this_ptr_conv.is_owned = false;
34249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34250         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
34251 }
34252
34253 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
34254         LDKUpdateFailMalformedHTLC this_ptr_conv;
34255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34256         this_ptr_conv.is_owned = false;
34257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34258         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
34259         return ret_conv;
34260 }
34261
34262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34263         LDKUpdateFailMalformedHTLC this_ptr_conv;
34264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34265         this_ptr_conv.is_owned = false;
34266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34267         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
34268 }
34269
34270 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
34271         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
34272 int64_t ret_ref = 0;
34273 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34274 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34275 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34276 ret_ref = (uintptr_t)ret_var.inner;
34277 if (ret_var.is_owned) {
34278         ret_ref |= 1;
34279 }
34280         return ret_ref;
34281 }
34282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34283         LDKUpdateFailMalformedHTLC arg_conv;
34284         arg_conv.inner = (void*)(arg & (~1));
34285         arg_conv.is_owned = false;
34286         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34287         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
34288         return ret_conv;
34289 }
34290
34291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34292         LDKUpdateFailMalformedHTLC orig_conv;
34293         orig_conv.inner = (void*)(orig & (~1));
34294         orig_conv.is_owned = false;
34295         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34296         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
34297         int64_t ret_ref = 0;
34298         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34299         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34300         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34301         ret_ref = (uintptr_t)ret_var.inner;
34302         if (ret_var.is_owned) {
34303                 ret_ref |= 1;
34304         }
34305         return ret_ref;
34306 }
34307
34308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34309         LDKCommitmentSigned this_obj_conv;
34310         this_obj_conv.inner = (void*)(this_obj & (~1));
34311         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34313         CommitmentSigned_free(this_obj_conv);
34314 }
34315
34316 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34317         LDKCommitmentSigned this_ptr_conv;
34318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34319         this_ptr_conv.is_owned = false;
34320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34321         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34322         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
34323         return ret_arr;
34324 }
34325
34326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34327         LDKCommitmentSigned this_ptr_conv;
34328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34329         this_ptr_conv.is_owned = false;
34330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34331         LDKThirtyTwoBytes val_ref;
34332         CHECK((*env)->GetArrayLength(env, val) == 32);
34333         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34334         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
34335 }
34336
34337 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34338         LDKCommitmentSigned this_ptr_conv;
34339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34340         this_ptr_conv.is_owned = false;
34341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34342         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34343         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
34344         return ret_arr;
34345 }
34346
34347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34348         LDKCommitmentSigned this_ptr_conv;
34349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34350         this_ptr_conv.is_owned = false;
34351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34352         LDKSignature val_ref;
34353         CHECK((*env)->GetArrayLength(env, val) == 64);
34354         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34355         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
34356 }
34357
34358 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr) {
34359         LDKCommitmentSigned this_ptr_conv;
34360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34361         this_ptr_conv.is_owned = false;
34362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34363         LDKCVec_SignatureZ ret_var = CommitmentSigned_get_htlc_signatures(&this_ptr_conv);
34364         jobjectArray ret_arr = NULL;
34365         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
34366         ;
34367         for (size_t i = 0; i < ret_var.datalen; i++) {
34368                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
34369                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
34370                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
34371         }
34372         
34373         FREE(ret_var.data);
34374         return ret_arr;
34375 }
34376
34377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
34378         LDKCommitmentSigned this_ptr_conv;
34379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34380         this_ptr_conv.is_owned = false;
34381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34382         LDKCVec_SignatureZ val_constr;
34383         val_constr.datalen = (*env)->GetArrayLength(env, val);
34384         if (val_constr.datalen > 0)
34385                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34386         else
34387                 val_constr.data = NULL;
34388         for (size_t i = 0; i < val_constr.datalen; i++) {
34389                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
34390                 LDKSignature val_conv_8_ref;
34391                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
34392                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
34393                 val_constr.data[i] = val_conv_8_ref;
34394         }
34395         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
34396 }
34397
34398 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) {
34399         LDKThirtyTwoBytes channel_id_arg_ref;
34400         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34401         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34402         LDKSignature signature_arg_ref;
34403         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34404         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34405         LDKCVec_SignatureZ htlc_signatures_arg_constr;
34406         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
34407         if (htlc_signatures_arg_constr.datalen > 0)
34408                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34409         else
34410                 htlc_signatures_arg_constr.data = NULL;
34411         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
34412                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
34413                 LDKSignature htlc_signatures_arg_conv_8_ref;
34414                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
34415                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
34416                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
34417         }
34418         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
34419         int64_t ret_ref = 0;
34420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34423         ret_ref = (uintptr_t)ret_var.inner;
34424         if (ret_var.is_owned) {
34425                 ret_ref |= 1;
34426         }
34427         return ret_ref;
34428 }
34429
34430 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
34431         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
34432 int64_t ret_ref = 0;
34433 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34434 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34435 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34436 ret_ref = (uintptr_t)ret_var.inner;
34437 if (ret_var.is_owned) {
34438         ret_ref |= 1;
34439 }
34440         return ret_ref;
34441 }
34442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34443         LDKCommitmentSigned arg_conv;
34444         arg_conv.inner = (void*)(arg & (~1));
34445         arg_conv.is_owned = false;
34446         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34447         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
34448         return ret_conv;
34449 }
34450
34451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34452         LDKCommitmentSigned orig_conv;
34453         orig_conv.inner = (void*)(orig & (~1));
34454         orig_conv.is_owned = false;
34455         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34456         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
34457         int64_t ret_ref = 0;
34458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34461         ret_ref = (uintptr_t)ret_var.inner;
34462         if (ret_var.is_owned) {
34463                 ret_ref |= 1;
34464         }
34465         return ret_ref;
34466 }
34467
34468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34469         LDKRevokeAndACK this_obj_conv;
34470         this_obj_conv.inner = (void*)(this_obj & (~1));
34471         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34473         RevokeAndACK_free(this_obj_conv);
34474 }
34475
34476 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34477         LDKRevokeAndACK this_ptr_conv;
34478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34479         this_ptr_conv.is_owned = false;
34480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34481         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34482         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
34483         return ret_arr;
34484 }
34485
34486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34487         LDKRevokeAndACK this_ptr_conv;
34488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34489         this_ptr_conv.is_owned = false;
34490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34491         LDKThirtyTwoBytes val_ref;
34492         CHECK((*env)->GetArrayLength(env, val) == 32);
34493         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34494         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
34495 }
34496
34497 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
34498         LDKRevokeAndACK this_ptr_conv;
34499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34500         this_ptr_conv.is_owned = false;
34501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34502         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34503         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
34504         return ret_arr;
34505 }
34506
34507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34508         LDKRevokeAndACK this_ptr_conv;
34509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34510         this_ptr_conv.is_owned = false;
34511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34512         LDKThirtyTwoBytes val_ref;
34513         CHECK((*env)->GetArrayLength(env, val) == 32);
34514         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34515         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
34516 }
34517
34518 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34519         LDKRevokeAndACK this_ptr_conv;
34520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34521         this_ptr_conv.is_owned = false;
34522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34523         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34524         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
34525         return ret_arr;
34526 }
34527
34528 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) {
34529         LDKRevokeAndACK this_ptr_conv;
34530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34531         this_ptr_conv.is_owned = false;
34532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34533         LDKPublicKey val_ref;
34534         CHECK((*env)->GetArrayLength(env, val) == 33);
34535         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34536         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
34537 }
34538
34539 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) {
34540         LDKThirtyTwoBytes channel_id_arg_ref;
34541         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34542         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34543         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
34544         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
34545         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
34546         LDKPublicKey next_per_commitment_point_arg_ref;
34547         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
34548         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
34549         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
34550         int64_t ret_ref = 0;
34551         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34552         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34554         ret_ref = (uintptr_t)ret_var.inner;
34555         if (ret_var.is_owned) {
34556                 ret_ref |= 1;
34557         }
34558         return ret_ref;
34559 }
34560
34561 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
34562         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
34563 int64_t ret_ref = 0;
34564 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34565 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34566 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34567 ret_ref = (uintptr_t)ret_var.inner;
34568 if (ret_var.is_owned) {
34569         ret_ref |= 1;
34570 }
34571         return ret_ref;
34572 }
34573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34574         LDKRevokeAndACK arg_conv;
34575         arg_conv.inner = (void*)(arg & (~1));
34576         arg_conv.is_owned = false;
34577         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34578         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
34579         return ret_conv;
34580 }
34581
34582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34583         LDKRevokeAndACK orig_conv;
34584         orig_conv.inner = (void*)(orig & (~1));
34585         orig_conv.is_owned = false;
34586         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34587         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
34588         int64_t ret_ref = 0;
34589         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34590         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34591         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34592         ret_ref = (uintptr_t)ret_var.inner;
34593         if (ret_var.is_owned) {
34594                 ret_ref |= 1;
34595         }
34596         return ret_ref;
34597 }
34598
34599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34600         LDKUpdateFee this_obj_conv;
34601         this_obj_conv.inner = (void*)(this_obj & (~1));
34602         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34604         UpdateFee_free(this_obj_conv);
34605 }
34606
34607 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34608         LDKUpdateFee this_ptr_conv;
34609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34610         this_ptr_conv.is_owned = false;
34611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34612         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34613         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
34614         return ret_arr;
34615 }
34616
34617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34618         LDKUpdateFee 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         LDKThirtyTwoBytes val_ref;
34623         CHECK((*env)->GetArrayLength(env, val) == 32);
34624         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34625         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
34626 }
34627
34628 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
34629         LDKUpdateFee this_ptr_conv;
34630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34631         this_ptr_conv.is_owned = false;
34632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34633         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
34634         return ret_conv;
34635 }
34636
34637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34638         LDKUpdateFee this_ptr_conv;
34639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34640         this_ptr_conv.is_owned = false;
34641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34642         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
34643 }
34644
34645 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) {
34646         LDKThirtyTwoBytes channel_id_arg_ref;
34647         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34648         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34649         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
34650         int64_t ret_ref = 0;
34651         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34652         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34654         ret_ref = (uintptr_t)ret_var.inner;
34655         if (ret_var.is_owned) {
34656                 ret_ref |= 1;
34657         }
34658         return ret_ref;
34659 }
34660
34661 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
34662         LDKUpdateFee ret_var = UpdateFee_clone(arg);
34663 int64_t ret_ref = 0;
34664 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34665 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34666 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34667 ret_ref = (uintptr_t)ret_var.inner;
34668 if (ret_var.is_owned) {
34669         ret_ref |= 1;
34670 }
34671         return ret_ref;
34672 }
34673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34674         LDKUpdateFee arg_conv;
34675         arg_conv.inner = (void*)(arg & (~1));
34676         arg_conv.is_owned = false;
34677         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34678         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
34679         return ret_conv;
34680 }
34681
34682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34683         LDKUpdateFee orig_conv;
34684         orig_conv.inner = (void*)(orig & (~1));
34685         orig_conv.is_owned = false;
34686         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34687         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
34688         int64_t ret_ref = 0;
34689         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34690         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34692         ret_ref = (uintptr_t)ret_var.inner;
34693         if (ret_var.is_owned) {
34694                 ret_ref |= 1;
34695         }
34696         return ret_ref;
34697 }
34698
34699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34700         LDKDataLossProtect this_obj_conv;
34701         this_obj_conv.inner = (void*)(this_obj & (~1));
34702         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34704         DataLossProtect_free(this_obj_conv);
34705 }
34706
34707 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
34708         LDKDataLossProtect this_ptr_conv;
34709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34710         this_ptr_conv.is_owned = false;
34711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34712         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34713         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
34714         return ret_arr;
34715 }
34716
34717 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) {
34718         LDKDataLossProtect this_ptr_conv;
34719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34720         this_ptr_conv.is_owned = false;
34721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34722         LDKThirtyTwoBytes val_ref;
34723         CHECK((*env)->GetArrayLength(env, val) == 32);
34724         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34725         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
34726 }
34727
34728 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34729         LDKDataLossProtect this_ptr_conv;
34730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34731         this_ptr_conv.is_owned = false;
34732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34733         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34734         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
34735         return ret_arr;
34736 }
34737
34738 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) {
34739         LDKDataLossProtect this_ptr_conv;
34740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34741         this_ptr_conv.is_owned = false;
34742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34743         LDKPublicKey val_ref;
34744         CHECK((*env)->GetArrayLength(env, val) == 33);
34745         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34746         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
34747 }
34748
34749 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) {
34750         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
34751         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
34752         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
34753         LDKPublicKey my_current_per_commitment_point_arg_ref;
34754         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
34755         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
34756         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
34757         int64_t ret_ref = 0;
34758         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34759         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34761         ret_ref = (uintptr_t)ret_var.inner;
34762         if (ret_var.is_owned) {
34763                 ret_ref |= 1;
34764         }
34765         return ret_ref;
34766 }
34767
34768 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
34769         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
34770 int64_t ret_ref = 0;
34771 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34772 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34773 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34774 ret_ref = (uintptr_t)ret_var.inner;
34775 if (ret_var.is_owned) {
34776         ret_ref |= 1;
34777 }
34778         return ret_ref;
34779 }
34780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34781         LDKDataLossProtect arg_conv;
34782         arg_conv.inner = (void*)(arg & (~1));
34783         arg_conv.is_owned = false;
34784         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34785         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
34786         return ret_conv;
34787 }
34788
34789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34790         LDKDataLossProtect orig_conv;
34791         orig_conv.inner = (void*)(orig & (~1));
34792         orig_conv.is_owned = false;
34793         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34794         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
34795         int64_t ret_ref = 0;
34796         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34797         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34798         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34799         ret_ref = (uintptr_t)ret_var.inner;
34800         if (ret_var.is_owned) {
34801                 ret_ref |= 1;
34802         }
34803         return ret_ref;
34804 }
34805
34806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34807         LDKChannelReestablish this_obj_conv;
34808         this_obj_conv.inner = (void*)(this_obj & (~1));
34809         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34811         ChannelReestablish_free(this_obj_conv);
34812 }
34813
34814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34815         LDKChannelReestablish this_ptr_conv;
34816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34817         this_ptr_conv.is_owned = false;
34818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34819         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34820         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
34821         return ret_arr;
34822 }
34823
34824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34825         LDKChannelReestablish this_ptr_conv;
34826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34827         this_ptr_conv.is_owned = false;
34828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34829         LDKThirtyTwoBytes val_ref;
34830         CHECK((*env)->GetArrayLength(env, val) == 32);
34831         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34832         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
34833 }
34834
34835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
34836         LDKChannelReestablish this_ptr_conv;
34837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34838         this_ptr_conv.is_owned = false;
34839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34840         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
34841         return ret_conv;
34842 }
34843
34844 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) {
34845         LDKChannelReestablish this_ptr_conv;
34846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34847         this_ptr_conv.is_owned = false;
34848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34849         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
34850 }
34851
34852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
34853         LDKChannelReestablish this_ptr_conv;
34854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34855         this_ptr_conv.is_owned = false;
34856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34857         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
34858         return ret_conv;
34859 }
34860
34861 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) {
34862         LDKChannelReestablish this_ptr_conv;
34863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34864         this_ptr_conv.is_owned = false;
34865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34866         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
34867 }
34868
34869 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
34870         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
34871 int64_t ret_ref = 0;
34872 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34873 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34874 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34875 ret_ref = (uintptr_t)ret_var.inner;
34876 if (ret_var.is_owned) {
34877         ret_ref |= 1;
34878 }
34879         return ret_ref;
34880 }
34881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34882         LDKChannelReestablish arg_conv;
34883         arg_conv.inner = (void*)(arg & (~1));
34884         arg_conv.is_owned = false;
34885         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34886         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
34887         return ret_conv;
34888 }
34889
34890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34891         LDKChannelReestablish orig_conv;
34892         orig_conv.inner = (void*)(orig & (~1));
34893         orig_conv.is_owned = false;
34894         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34895         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
34896         int64_t ret_ref = 0;
34897         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34898         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34900         ret_ref = (uintptr_t)ret_var.inner;
34901         if (ret_var.is_owned) {
34902                 ret_ref |= 1;
34903         }
34904         return ret_ref;
34905 }
34906
34907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34908         LDKAnnouncementSignatures this_obj_conv;
34909         this_obj_conv.inner = (void*)(this_obj & (~1));
34910         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34912         AnnouncementSignatures_free(this_obj_conv);
34913 }
34914
34915 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34916         LDKAnnouncementSignatures this_ptr_conv;
34917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34918         this_ptr_conv.is_owned = false;
34919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34920         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34921         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
34922         return ret_arr;
34923 }
34924
34925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34926         LDKAnnouncementSignatures this_ptr_conv;
34927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34928         this_ptr_conv.is_owned = false;
34929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34930         LDKThirtyTwoBytes val_ref;
34931         CHECK((*env)->GetArrayLength(env, val) == 32);
34932         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34933         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
34934 }
34935
34936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34937         LDKAnnouncementSignatures this_ptr_conv;
34938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34939         this_ptr_conv.is_owned = false;
34940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34941         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
34942         return ret_conv;
34943 }
34944
34945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34946         LDKAnnouncementSignatures this_ptr_conv;
34947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34948         this_ptr_conv.is_owned = false;
34949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34950         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
34951 }
34952
34953 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34954         LDKAnnouncementSignatures this_ptr_conv;
34955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34956         this_ptr_conv.is_owned = false;
34957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34958         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34959         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
34960         return ret_arr;
34961 }
34962
34963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34964         LDKAnnouncementSignatures 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         LDKSignature val_ref;
34969         CHECK((*env)->GetArrayLength(env, val) == 64);
34970         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34971         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
34972 }
34973
34974 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34975         LDKAnnouncementSignatures this_ptr_conv;
34976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34977         this_ptr_conv.is_owned = false;
34978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34979         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34980         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
34981         return ret_arr;
34982 }
34983
34984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34985         LDKAnnouncementSignatures this_ptr_conv;
34986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34987         this_ptr_conv.is_owned = false;
34988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34989         LDKSignature val_ref;
34990         CHECK((*env)->GetArrayLength(env, val) == 64);
34991         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34992         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
34993 }
34994
34995 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) {
34996         LDKThirtyTwoBytes channel_id_arg_ref;
34997         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34998         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34999         LDKSignature node_signature_arg_ref;
35000         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
35001         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
35002         LDKSignature bitcoin_signature_arg_ref;
35003         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
35004         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
35005         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
35006         int64_t ret_ref = 0;
35007         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35008         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35010         ret_ref = (uintptr_t)ret_var.inner;
35011         if (ret_var.is_owned) {
35012                 ret_ref |= 1;
35013         }
35014         return ret_ref;
35015 }
35016
35017 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
35018         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
35019 int64_t ret_ref = 0;
35020 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35021 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35022 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35023 ret_ref = (uintptr_t)ret_var.inner;
35024 if (ret_var.is_owned) {
35025         ret_ref |= 1;
35026 }
35027         return ret_ref;
35028 }
35029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35030         LDKAnnouncementSignatures arg_conv;
35031         arg_conv.inner = (void*)(arg & (~1));
35032         arg_conv.is_owned = false;
35033         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35034         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
35035         return ret_conv;
35036 }
35037
35038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35039         LDKAnnouncementSignatures orig_conv;
35040         orig_conv.inner = (void*)(orig & (~1));
35041         orig_conv.is_owned = false;
35042         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35043         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
35044         int64_t ret_ref = 0;
35045         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35046         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35048         ret_ref = (uintptr_t)ret_var.inner;
35049         if (ret_var.is_owned) {
35050                 ret_ref |= 1;
35051         }
35052         return ret_ref;
35053 }
35054
35055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35056         if ((this_ptr & 1) != 0) return;
35057         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35058         CHECK_ACCESS(this_ptr_ptr);
35059         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
35060         FREE((void*)this_ptr);
35061         NetAddress_free(this_ptr_conv);
35062 }
35063
35064 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
35065         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35066         *ret_copy = NetAddress_clone(arg);
35067 int64_t ret_ref = (uintptr_t)ret_copy;
35068         return ret_ref;
35069 }
35070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35071         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
35072         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
35073         return ret_conv;
35074 }
35075
35076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35077         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
35078         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35079         *ret_copy = NetAddress_clone(orig_conv);
35080         int64_t ret_ref = (uintptr_t)ret_copy;
35081         return ret_ref;
35082 }
35083
35084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
35085         LDKFourBytes addr_ref;
35086         CHECK((*env)->GetArrayLength(env, addr) == 4);
35087         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
35088         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35089         *ret_copy = NetAddress_ipv4(addr_ref, port);
35090         int64_t ret_ref = (uintptr_t)ret_copy;
35091         return ret_ref;
35092 }
35093
35094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
35095         LDKSixteenBytes addr_ref;
35096         CHECK((*env)->GetArrayLength(env, addr) == 16);
35097         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
35098         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35099         *ret_copy = NetAddress_ipv6(addr_ref, port);
35100         int64_t ret_ref = (uintptr_t)ret_copy;
35101         return ret_ref;
35102 }
35103
35104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
35105         LDKTwelveBytes a_ref;
35106         CHECK((*env)->GetArrayLength(env, a) == 12);
35107         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
35108         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35109         *ret_copy = NetAddress_onion_v2(a_ref);
35110         int64_t ret_ref = (uintptr_t)ret_copy;
35111         return ret_ref;
35112 }
35113
35114 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) {
35115         LDKThirtyTwoBytes ed25519_pubkey_ref;
35116         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
35117         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
35118         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35119         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
35120         int64_t ret_ref = (uintptr_t)ret_copy;
35121         return ret_ref;
35122 }
35123
35124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1hostname(JNIEnv *env, jclass clz, int64_t hostname, int16_t port) {
35125         LDKHostname hostname_conv;
35126         hostname_conv.inner = (void*)(hostname & (~1));
35127         hostname_conv.is_owned = (hostname & 1) || (hostname == 0);
35128         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
35129         hostname_conv = Hostname_clone(&hostname_conv);
35130         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35131         *ret_copy = NetAddress_hostname(hostname_conv, port);
35132         int64_t ret_ref = (uintptr_t)ret_copy;
35133         return ret_ref;
35134 }
35135
35136 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
35137         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
35138         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
35139         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35140         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35141         CVec_u8Z_free(ret_var);
35142         return ret_arr;
35143 }
35144
35145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35146         LDKu8slice ser_ref;
35147         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35148         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35149         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
35150         *ret_conv = NetAddress_read(ser_ref);
35151         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35152         return (int64_t)ret_conv;
35153 }
35154
35155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35156         LDKUnsignedNodeAnnouncement this_obj_conv;
35157         this_obj_conv.inner = (void*)(this_obj & (~1));
35158         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35160         UnsignedNodeAnnouncement_free(this_obj_conv);
35161 }
35162
35163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
35164         LDKUnsignedNodeAnnouncement this_ptr_conv;
35165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35166         this_ptr_conv.is_owned = false;
35167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35168         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
35169         int64_t ret_ref = 0;
35170         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35171         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35173         ret_ref = (uintptr_t)ret_var.inner;
35174         if (ret_var.is_owned) {
35175                 ret_ref |= 1;
35176         }
35177         return ret_ref;
35178 }
35179
35180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35181         LDKUnsignedNodeAnnouncement this_ptr_conv;
35182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35183         this_ptr_conv.is_owned = false;
35184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35185         LDKNodeFeatures val_conv;
35186         val_conv.inner = (void*)(val & (~1));
35187         val_conv.is_owned = (val & 1) || (val == 0);
35188         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35189         val_conv = NodeFeatures_clone(&val_conv);
35190         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
35191 }
35192
35193 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
35194         LDKUnsignedNodeAnnouncement this_ptr_conv;
35195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35196         this_ptr_conv.is_owned = false;
35197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35198         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
35199         return ret_conv;
35200 }
35201
35202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35203         LDKUnsignedNodeAnnouncement this_ptr_conv;
35204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35205         this_ptr_conv.is_owned = false;
35206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35207         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
35208 }
35209
35210 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35211         LDKUnsignedNodeAnnouncement this_ptr_conv;
35212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35213         this_ptr_conv.is_owned = false;
35214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35215         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35216         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
35217         return ret_arr;
35218 }
35219
35220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35221         LDKUnsignedNodeAnnouncement this_ptr_conv;
35222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35223         this_ptr_conv.is_owned = false;
35224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35225         LDKPublicKey val_ref;
35226         CHECK((*env)->GetArrayLength(env, val) == 33);
35227         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35228         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
35229 }
35230
35231 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
35232         LDKUnsignedNodeAnnouncement this_ptr_conv;
35233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35234         this_ptr_conv.is_owned = false;
35235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35236         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
35237         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
35238         return ret_arr;
35239 }
35240
35241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35242         LDKUnsignedNodeAnnouncement 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         LDKThreeBytes val_ref;
35247         CHECK((*env)->GetArrayLength(env, val) == 3);
35248         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
35249         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
35250 }
35251
35252 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
35253         LDKUnsignedNodeAnnouncement this_ptr_conv;
35254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35255         this_ptr_conv.is_owned = false;
35256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35257         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35258         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
35259         return ret_arr;
35260 }
35261
35262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35263         LDKUnsignedNodeAnnouncement this_ptr_conv;
35264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35265         this_ptr_conv.is_owned = false;
35266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35267         LDKThirtyTwoBytes val_ref;
35268         CHECK((*env)->GetArrayLength(env, val) == 32);
35269         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35270         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
35271 }
35272
35273 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
35274         LDKUnsignedNodeAnnouncement this_ptr_conv;
35275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35276         this_ptr_conv.is_owned = false;
35277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35278         LDKCVec_NetAddressZ ret_var = UnsignedNodeAnnouncement_get_addresses(&this_ptr_conv);
35279         int64_tArray ret_arr = NULL;
35280         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35281         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35282         for (size_t m = 0; m < ret_var.datalen; m++) {
35283                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35284                 *ret_conv_12_copy = ret_var.data[m];
35285                 int64_t ret_conv_12_ref = (uintptr_t)ret_conv_12_copy;
35286                 ret_arr_ptr[m] = ret_conv_12_ref;
35287         }
35288         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35289         FREE(ret_var.data);
35290         return ret_arr;
35291 }
35292
35293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35294         LDKUnsignedNodeAnnouncement this_ptr_conv;
35295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35296         this_ptr_conv.is_owned = false;
35297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35298         LDKCVec_NetAddressZ val_constr;
35299         val_constr.datalen = (*env)->GetArrayLength(env, val);
35300         if (val_constr.datalen > 0)
35301                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
35302         else
35303                 val_constr.data = NULL;
35304         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35305         for (size_t m = 0; m < val_constr.datalen; m++) {
35306                 int64_t val_conv_12 = val_vals[m];
35307                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
35308                 CHECK_ACCESS(val_conv_12_ptr);
35309                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
35310                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
35311                 val_constr.data[m] = val_conv_12_conv;
35312         }
35313         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35314         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
35315 }
35316
35317 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
35318         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
35319 int64_t ret_ref = 0;
35320 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35321 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35322 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35323 ret_ref = (uintptr_t)ret_var.inner;
35324 if (ret_var.is_owned) {
35325         ret_ref |= 1;
35326 }
35327         return ret_ref;
35328 }
35329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35330         LDKUnsignedNodeAnnouncement arg_conv;
35331         arg_conv.inner = (void*)(arg & (~1));
35332         arg_conv.is_owned = false;
35333         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35334         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
35335         return ret_conv;
35336 }
35337
35338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35339         LDKUnsignedNodeAnnouncement orig_conv;
35340         orig_conv.inner = (void*)(orig & (~1));
35341         orig_conv.is_owned = false;
35342         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35343         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
35344         int64_t ret_ref = 0;
35345         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35346         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35348         ret_ref = (uintptr_t)ret_var.inner;
35349         if (ret_var.is_owned) {
35350                 ret_ref |= 1;
35351         }
35352         return ret_ref;
35353 }
35354
35355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35356         LDKNodeAnnouncement this_obj_conv;
35357         this_obj_conv.inner = (void*)(this_obj & (~1));
35358         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35360         NodeAnnouncement_free(this_obj_conv);
35361 }
35362
35363 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
35364         LDKNodeAnnouncement this_ptr_conv;
35365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35366         this_ptr_conv.is_owned = false;
35367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35368         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35369         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
35370         return ret_arr;
35371 }
35372
35373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35374         LDKNodeAnnouncement this_ptr_conv;
35375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35376         this_ptr_conv.is_owned = false;
35377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35378         LDKSignature val_ref;
35379         CHECK((*env)->GetArrayLength(env, val) == 64);
35380         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35381         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
35382 }
35383
35384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
35385         LDKNodeAnnouncement this_ptr_conv;
35386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35387         this_ptr_conv.is_owned = false;
35388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35389         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
35390         int64_t ret_ref = 0;
35391         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35392         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35394         ret_ref = (uintptr_t)ret_var.inner;
35395         if (ret_var.is_owned) {
35396                 ret_ref |= 1;
35397         }
35398         return ret_ref;
35399 }
35400
35401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35402         LDKNodeAnnouncement this_ptr_conv;
35403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35404         this_ptr_conv.is_owned = false;
35405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35406         LDKUnsignedNodeAnnouncement val_conv;
35407         val_conv.inner = (void*)(val & (~1));
35408         val_conv.is_owned = (val & 1) || (val == 0);
35409         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35410         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
35411         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
35412 }
35413
35414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
35415         LDKSignature signature_arg_ref;
35416         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
35417         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
35418         LDKUnsignedNodeAnnouncement contents_arg_conv;
35419         contents_arg_conv.inner = (void*)(contents_arg & (~1));
35420         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
35421         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
35422         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
35423         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
35424         int64_t ret_ref = 0;
35425         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35426         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35428         ret_ref = (uintptr_t)ret_var.inner;
35429         if (ret_var.is_owned) {
35430                 ret_ref |= 1;
35431         }
35432         return ret_ref;
35433 }
35434
35435 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
35436         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
35437 int64_t ret_ref = 0;
35438 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35439 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35440 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35441 ret_ref = (uintptr_t)ret_var.inner;
35442 if (ret_var.is_owned) {
35443         ret_ref |= 1;
35444 }
35445         return ret_ref;
35446 }
35447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35448         LDKNodeAnnouncement arg_conv;
35449         arg_conv.inner = (void*)(arg & (~1));
35450         arg_conv.is_owned = false;
35451         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35452         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
35453         return ret_conv;
35454 }
35455
35456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35457         LDKNodeAnnouncement orig_conv;
35458         orig_conv.inner = (void*)(orig & (~1));
35459         orig_conv.is_owned = false;
35460         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35461         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
35462         int64_t ret_ref = 0;
35463         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35464         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35466         ret_ref = (uintptr_t)ret_var.inner;
35467         if (ret_var.is_owned) {
35468                 ret_ref |= 1;
35469         }
35470         return ret_ref;
35471 }
35472
35473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35474         LDKUnsignedChannelAnnouncement this_obj_conv;
35475         this_obj_conv.inner = (void*)(this_obj & (~1));
35476         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35478         UnsignedChannelAnnouncement_free(this_obj_conv);
35479 }
35480
35481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
35482         LDKUnsignedChannelAnnouncement this_ptr_conv;
35483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35484         this_ptr_conv.is_owned = false;
35485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35486         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
35487         int64_t ret_ref = 0;
35488         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35489         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35491         ret_ref = (uintptr_t)ret_var.inner;
35492         if (ret_var.is_owned) {
35493                 ret_ref |= 1;
35494         }
35495         return ret_ref;
35496 }
35497
35498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35499         LDKUnsignedChannelAnnouncement this_ptr_conv;
35500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35501         this_ptr_conv.is_owned = false;
35502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35503         LDKChannelFeatures val_conv;
35504         val_conv.inner = (void*)(val & (~1));
35505         val_conv.is_owned = (val & 1) || (val == 0);
35506         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35507         val_conv = ChannelFeatures_clone(&val_conv);
35508         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
35509 }
35510
35511 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35512         LDKUnsignedChannelAnnouncement this_ptr_conv;
35513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35514         this_ptr_conv.is_owned = false;
35515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35516         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35517         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
35518         return ret_arr;
35519 }
35520
35521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35522         LDKUnsignedChannelAnnouncement this_ptr_conv;
35523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35524         this_ptr_conv.is_owned = false;
35525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35526         LDKThirtyTwoBytes val_ref;
35527         CHECK((*env)->GetArrayLength(env, val) == 32);
35528         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35529         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
35530 }
35531
35532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35533         LDKUnsignedChannelAnnouncement this_ptr_conv;
35534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35535         this_ptr_conv.is_owned = false;
35536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35537         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
35538         return ret_conv;
35539 }
35540
35541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35542         LDKUnsignedChannelAnnouncement this_ptr_conv;
35543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35544         this_ptr_conv.is_owned = false;
35545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35546         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
35547 }
35548
35549 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
35550         LDKUnsignedChannelAnnouncement this_ptr_conv;
35551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35552         this_ptr_conv.is_owned = false;
35553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35554         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35555         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
35556         return ret_arr;
35557 }
35558
35559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35560         LDKUnsignedChannelAnnouncement this_ptr_conv;
35561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35562         this_ptr_conv.is_owned = false;
35563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35564         LDKPublicKey val_ref;
35565         CHECK((*env)->GetArrayLength(env, val) == 33);
35566         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35567         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
35568 }
35569
35570 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
35571         LDKUnsignedChannelAnnouncement this_ptr_conv;
35572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35573         this_ptr_conv.is_owned = false;
35574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35575         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35576         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
35577         return ret_arr;
35578 }
35579
35580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35581         LDKUnsignedChannelAnnouncement this_ptr_conv;
35582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35583         this_ptr_conv.is_owned = false;
35584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35585         LDKPublicKey val_ref;
35586         CHECK((*env)->GetArrayLength(env, val) == 33);
35587         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35588         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
35589 }
35590
35591 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
35592         LDKUnsignedChannelAnnouncement this_ptr_conv;
35593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35594         this_ptr_conv.is_owned = false;
35595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35596         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35597         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
35598         return ret_arr;
35599 }
35600
35601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35602         LDKUnsignedChannelAnnouncement this_ptr_conv;
35603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35604         this_ptr_conv.is_owned = false;
35605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35606         LDKPublicKey val_ref;
35607         CHECK((*env)->GetArrayLength(env, val) == 33);
35608         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35609         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
35610 }
35611
35612 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
35613         LDKUnsignedChannelAnnouncement this_ptr_conv;
35614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35615         this_ptr_conv.is_owned = false;
35616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35617         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35618         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
35619         return ret_arr;
35620 }
35621
35622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35623         LDKUnsignedChannelAnnouncement this_ptr_conv;
35624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35625         this_ptr_conv.is_owned = false;
35626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35627         LDKPublicKey val_ref;
35628         CHECK((*env)->GetArrayLength(env, val) == 33);
35629         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35630         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
35631 }
35632
35633 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
35634         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
35635 int64_t ret_ref = 0;
35636 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35637 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35638 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35639 ret_ref = (uintptr_t)ret_var.inner;
35640 if (ret_var.is_owned) {
35641         ret_ref |= 1;
35642 }
35643         return ret_ref;
35644 }
35645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35646         LDKUnsignedChannelAnnouncement arg_conv;
35647         arg_conv.inner = (void*)(arg & (~1));
35648         arg_conv.is_owned = false;
35649         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35650         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
35651         return ret_conv;
35652 }
35653
35654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35655         LDKUnsignedChannelAnnouncement orig_conv;
35656         orig_conv.inner = (void*)(orig & (~1));
35657         orig_conv.is_owned = false;
35658         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35659         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
35660         int64_t ret_ref = 0;
35661         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35662         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35663         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35664         ret_ref = (uintptr_t)ret_var.inner;
35665         if (ret_var.is_owned) {
35666                 ret_ref |= 1;
35667         }
35668         return ret_ref;
35669 }
35670
35671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35672         LDKChannelAnnouncement this_obj_conv;
35673         this_obj_conv.inner = (void*)(this_obj & (~1));
35674         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35676         ChannelAnnouncement_free(this_obj_conv);
35677 }
35678
35679 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
35680         LDKChannelAnnouncement this_ptr_conv;
35681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35682         this_ptr_conv.is_owned = false;
35683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35684         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35685         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
35686         return ret_arr;
35687 }
35688
35689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35690         LDKChannelAnnouncement this_ptr_conv;
35691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35692         this_ptr_conv.is_owned = false;
35693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35694         LDKSignature val_ref;
35695         CHECK((*env)->GetArrayLength(env, val) == 64);
35696         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35697         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
35698 }
35699
35700 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
35701         LDKChannelAnnouncement this_ptr_conv;
35702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35703         this_ptr_conv.is_owned = false;
35704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35705         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35706         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
35707         return ret_arr;
35708 }
35709
35710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35711         LDKChannelAnnouncement this_ptr_conv;
35712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35713         this_ptr_conv.is_owned = false;
35714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35715         LDKSignature val_ref;
35716         CHECK((*env)->GetArrayLength(env, val) == 64);
35717         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35718         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
35719 }
35720
35721 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
35722         LDKChannelAnnouncement this_ptr_conv;
35723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35724         this_ptr_conv.is_owned = false;
35725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35726         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35727         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
35728         return ret_arr;
35729 }
35730
35731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35732         LDKChannelAnnouncement this_ptr_conv;
35733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35734         this_ptr_conv.is_owned = false;
35735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35736         LDKSignature val_ref;
35737         CHECK((*env)->GetArrayLength(env, val) == 64);
35738         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35739         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
35740 }
35741
35742 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
35743         LDKChannelAnnouncement this_ptr_conv;
35744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35745         this_ptr_conv.is_owned = false;
35746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35747         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35748         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
35749         return ret_arr;
35750 }
35751
35752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35753         LDKChannelAnnouncement this_ptr_conv;
35754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35755         this_ptr_conv.is_owned = false;
35756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35757         LDKSignature val_ref;
35758         CHECK((*env)->GetArrayLength(env, val) == 64);
35759         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35760         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
35761 }
35762
35763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
35764         LDKChannelAnnouncement 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         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
35769         int64_t ret_ref = 0;
35770         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35771         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35773         ret_ref = (uintptr_t)ret_var.inner;
35774         if (ret_var.is_owned) {
35775                 ret_ref |= 1;
35776         }
35777         return ret_ref;
35778 }
35779
35780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35781         LDKChannelAnnouncement this_ptr_conv;
35782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35783         this_ptr_conv.is_owned = false;
35784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35785         LDKUnsignedChannelAnnouncement val_conv;
35786         val_conv.inner = (void*)(val & (~1));
35787         val_conv.is_owned = (val & 1) || (val == 0);
35788         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35789         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
35790         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
35791 }
35792
35793 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) {
35794         LDKSignature node_signature_1_arg_ref;
35795         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
35796         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
35797         LDKSignature node_signature_2_arg_ref;
35798         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
35799         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
35800         LDKSignature bitcoin_signature_1_arg_ref;
35801         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
35802         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
35803         LDKSignature bitcoin_signature_2_arg_ref;
35804         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
35805         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
35806         LDKUnsignedChannelAnnouncement contents_arg_conv;
35807         contents_arg_conv.inner = (void*)(contents_arg & (~1));
35808         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
35809         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
35810         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
35811         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);
35812         int64_t ret_ref = 0;
35813         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35814         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35815         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35816         ret_ref = (uintptr_t)ret_var.inner;
35817         if (ret_var.is_owned) {
35818                 ret_ref |= 1;
35819         }
35820         return ret_ref;
35821 }
35822
35823 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
35824         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
35825 int64_t ret_ref = 0;
35826 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35827 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35828 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35829 ret_ref = (uintptr_t)ret_var.inner;
35830 if (ret_var.is_owned) {
35831         ret_ref |= 1;
35832 }
35833         return ret_ref;
35834 }
35835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35836         LDKChannelAnnouncement arg_conv;
35837         arg_conv.inner = (void*)(arg & (~1));
35838         arg_conv.is_owned = false;
35839         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35840         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
35841         return ret_conv;
35842 }
35843
35844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35845         LDKChannelAnnouncement orig_conv;
35846         orig_conv.inner = (void*)(orig & (~1));
35847         orig_conv.is_owned = false;
35848         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35849         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
35850         int64_t ret_ref = 0;
35851         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35852         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35854         ret_ref = (uintptr_t)ret_var.inner;
35855         if (ret_var.is_owned) {
35856                 ret_ref |= 1;
35857         }
35858         return ret_ref;
35859 }
35860
35861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35862         LDKUnsignedChannelUpdate this_obj_conv;
35863         this_obj_conv.inner = (void*)(this_obj & (~1));
35864         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35866         UnsignedChannelUpdate_free(this_obj_conv);
35867 }
35868
35869 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35870         LDKUnsignedChannelUpdate this_ptr_conv;
35871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35872         this_ptr_conv.is_owned = false;
35873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35874         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35875         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
35876         return ret_arr;
35877 }
35878
35879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35880         LDKUnsignedChannelUpdate this_ptr_conv;
35881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35882         this_ptr_conv.is_owned = false;
35883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35884         LDKThirtyTwoBytes val_ref;
35885         CHECK((*env)->GetArrayLength(env, val) == 32);
35886         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35887         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
35888 }
35889
35890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35891         LDKUnsignedChannelUpdate this_ptr_conv;
35892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35893         this_ptr_conv.is_owned = false;
35894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35895         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
35896         return ret_conv;
35897 }
35898
35899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35900         LDKUnsignedChannelUpdate this_ptr_conv;
35901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35902         this_ptr_conv.is_owned = false;
35903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35904         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
35905 }
35906
35907 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
35908         LDKUnsignedChannelUpdate this_ptr_conv;
35909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35910         this_ptr_conv.is_owned = false;
35911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35912         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
35913         return ret_conv;
35914 }
35915
35916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35917         LDKUnsignedChannelUpdate this_ptr_conv;
35918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35919         this_ptr_conv.is_owned = false;
35920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35921         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
35922 }
35923
35924 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
35925         LDKUnsignedChannelUpdate this_ptr_conv;
35926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35927         this_ptr_conv.is_owned = false;
35928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35929         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
35930         return ret_conv;
35931 }
35932
35933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
35934         LDKUnsignedChannelUpdate this_ptr_conv;
35935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35936         this_ptr_conv.is_owned = false;
35937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35938         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
35939 }
35940
35941 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
35942         LDKUnsignedChannelUpdate this_ptr_conv;
35943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35944         this_ptr_conv.is_owned = false;
35945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35946         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
35947         return ret_conv;
35948 }
35949
35950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35951         LDKUnsignedChannelUpdate this_ptr_conv;
35952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35953         this_ptr_conv.is_owned = false;
35954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35955         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
35956 }
35957
35958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35959         LDKUnsignedChannelUpdate this_ptr_conv;
35960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35961         this_ptr_conv.is_owned = false;
35962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35963         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
35964         return ret_conv;
35965 }
35966
35967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35968         LDKUnsignedChannelUpdate this_ptr_conv;
35969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35970         this_ptr_conv.is_owned = false;
35971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35972         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
35973 }
35974
35975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35976         LDKUnsignedChannelUpdate this_ptr_conv;
35977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35978         this_ptr_conv.is_owned = false;
35979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35980         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
35981         return ret_conv;
35982 }
35983
35984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35985         LDKUnsignedChannelUpdate this_ptr_conv;
35986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35987         this_ptr_conv.is_owned = false;
35988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35989         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
35990 }
35991
35992 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35993         LDKUnsignedChannelUpdate this_ptr_conv;
35994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35995         this_ptr_conv.is_owned = false;
35996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35997         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
35998         return ret_conv;
35999 }
36000
36001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36002         LDKUnsignedChannelUpdate this_ptr_conv;
36003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36004         this_ptr_conv.is_owned = false;
36005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36006         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
36007 }
36008
36009 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
36010         LDKUnsignedChannelUpdate this_ptr_conv;
36011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36012         this_ptr_conv.is_owned = false;
36013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36014         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
36015         return ret_conv;
36016 }
36017
36018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36019         LDKUnsignedChannelUpdate this_ptr_conv;
36020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36021         this_ptr_conv.is_owned = false;
36022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36023         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
36024 }
36025
36026 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
36027         LDKUnsignedChannelUpdate this_ptr_conv;
36028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36029         this_ptr_conv.is_owned = false;
36030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36031         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_get_excess_data(&this_ptr_conv);
36032         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36033         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36034         CVec_u8Z_free(ret_var);
36035         return ret_arr;
36036 }
36037
36038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36039         LDKUnsignedChannelUpdate this_ptr_conv;
36040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36041         this_ptr_conv.is_owned = false;
36042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36043         LDKCVec_u8Z val_ref;
36044         val_ref.datalen = (*env)->GetArrayLength(env, val);
36045         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
36046         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
36047         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
36048 }
36049
36050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, int64_t short_channel_id_arg, int32_t timestamp_arg, int8_t flags_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int8_tArray excess_data_arg) {
36051         LDKThirtyTwoBytes chain_hash_arg_ref;
36052         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36053         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36054         LDKCVec_u8Z excess_data_arg_ref;
36055         excess_data_arg_ref.datalen = (*env)->GetArrayLength(env, excess_data_arg);
36056         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
36057         (*env)->GetByteArrayRegion(env, excess_data_arg, 0, excess_data_arg_ref.datalen, excess_data_arg_ref.data);
36058         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_new(chain_hash_arg_ref, short_channel_id_arg, timestamp_arg, flags_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fee_base_msat_arg, fee_proportional_millionths_arg, excess_data_arg_ref);
36059         int64_t ret_ref = 0;
36060         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36061         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36062         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36063         ret_ref = (uintptr_t)ret_var.inner;
36064         if (ret_var.is_owned) {
36065                 ret_ref |= 1;
36066         }
36067         return ret_ref;
36068 }
36069
36070 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
36071         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
36072 int64_t ret_ref = 0;
36073 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36074 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36075 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36076 ret_ref = (uintptr_t)ret_var.inner;
36077 if (ret_var.is_owned) {
36078         ret_ref |= 1;
36079 }
36080         return ret_ref;
36081 }
36082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36083         LDKUnsignedChannelUpdate arg_conv;
36084         arg_conv.inner = (void*)(arg & (~1));
36085         arg_conv.is_owned = false;
36086         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36087         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
36088         return ret_conv;
36089 }
36090
36091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36092         LDKUnsignedChannelUpdate orig_conv;
36093         orig_conv.inner = (void*)(orig & (~1));
36094         orig_conv.is_owned = false;
36095         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36096         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
36097         int64_t ret_ref = 0;
36098         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36099         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36101         ret_ref = (uintptr_t)ret_var.inner;
36102         if (ret_var.is_owned) {
36103                 ret_ref |= 1;
36104         }
36105         return ret_ref;
36106 }
36107
36108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36109         LDKChannelUpdate this_obj_conv;
36110         this_obj_conv.inner = (void*)(this_obj & (~1));
36111         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36113         ChannelUpdate_free(this_obj_conv);
36114 }
36115
36116 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36117         LDKChannelUpdate this_ptr_conv;
36118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36119         this_ptr_conv.is_owned = false;
36120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36121         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36122         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
36123         return ret_arr;
36124 }
36125
36126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36127         LDKChannelUpdate this_ptr_conv;
36128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36129         this_ptr_conv.is_owned = false;
36130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36131         LDKSignature val_ref;
36132         CHECK((*env)->GetArrayLength(env, val) == 64);
36133         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36134         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
36135 }
36136
36137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
36138         LDKChannelUpdate this_ptr_conv;
36139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36140         this_ptr_conv.is_owned = false;
36141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36142         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
36143         int64_t ret_ref = 0;
36144         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36145         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36147         ret_ref = (uintptr_t)ret_var.inner;
36148         if (ret_var.is_owned) {
36149                 ret_ref |= 1;
36150         }
36151         return ret_ref;
36152 }
36153
36154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36155         LDKChannelUpdate this_ptr_conv;
36156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36157         this_ptr_conv.is_owned = false;
36158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36159         LDKUnsignedChannelUpdate val_conv;
36160         val_conv.inner = (void*)(val & (~1));
36161         val_conv.is_owned = (val & 1) || (val == 0);
36162         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36163         val_conv = UnsignedChannelUpdate_clone(&val_conv);
36164         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
36165 }
36166
36167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
36168         LDKSignature signature_arg_ref;
36169         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36170         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36171         LDKUnsignedChannelUpdate contents_arg_conv;
36172         contents_arg_conv.inner = (void*)(contents_arg & (~1));
36173         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
36174         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
36175         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
36176         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
36177         int64_t ret_ref = 0;
36178         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36179         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36181         ret_ref = (uintptr_t)ret_var.inner;
36182         if (ret_var.is_owned) {
36183                 ret_ref |= 1;
36184         }
36185         return ret_ref;
36186 }
36187
36188 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
36189         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
36190 int64_t ret_ref = 0;
36191 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36192 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36193 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36194 ret_ref = (uintptr_t)ret_var.inner;
36195 if (ret_var.is_owned) {
36196         ret_ref |= 1;
36197 }
36198         return ret_ref;
36199 }
36200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36201         LDKChannelUpdate arg_conv;
36202         arg_conv.inner = (void*)(arg & (~1));
36203         arg_conv.is_owned = false;
36204         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36205         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
36206         return ret_conv;
36207 }
36208
36209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36210         LDKChannelUpdate orig_conv;
36211         orig_conv.inner = (void*)(orig & (~1));
36212         orig_conv.is_owned = false;
36213         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36214         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
36215         int64_t ret_ref = 0;
36216         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36217         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36219         ret_ref = (uintptr_t)ret_var.inner;
36220         if (ret_var.is_owned) {
36221                 ret_ref |= 1;
36222         }
36223         return ret_ref;
36224 }
36225
36226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36227         LDKQueryChannelRange this_obj_conv;
36228         this_obj_conv.inner = (void*)(this_obj & (~1));
36229         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36231         QueryChannelRange_free(this_obj_conv);
36232 }
36233
36234 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36235         LDKQueryChannelRange this_ptr_conv;
36236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36237         this_ptr_conv.is_owned = false;
36238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36239         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36240         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
36241         return ret_arr;
36242 }
36243
36244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36245         LDKQueryChannelRange this_ptr_conv;
36246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36247         this_ptr_conv.is_owned = false;
36248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36249         LDKThirtyTwoBytes val_ref;
36250         CHECK((*env)->GetArrayLength(env, val) == 32);
36251         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36252         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
36253 }
36254
36255 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
36256         LDKQueryChannelRange this_ptr_conv;
36257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36258         this_ptr_conv.is_owned = false;
36259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36260         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
36261         return ret_conv;
36262 }
36263
36264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36265         LDKQueryChannelRange this_ptr_conv;
36266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36267         this_ptr_conv.is_owned = false;
36268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36269         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
36270 }
36271
36272 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
36273         LDKQueryChannelRange this_ptr_conv;
36274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36275         this_ptr_conv.is_owned = false;
36276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36277         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
36278         return ret_conv;
36279 }
36280
36281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36282         LDKQueryChannelRange this_ptr_conv;
36283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36284         this_ptr_conv.is_owned = false;
36285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36286         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
36287 }
36288
36289 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) {
36290         LDKThirtyTwoBytes chain_hash_arg_ref;
36291         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36292         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36293         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
36294         int64_t ret_ref = 0;
36295         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36296         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36298         ret_ref = (uintptr_t)ret_var.inner;
36299         if (ret_var.is_owned) {
36300                 ret_ref |= 1;
36301         }
36302         return ret_ref;
36303 }
36304
36305 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
36306         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
36307 int64_t ret_ref = 0;
36308 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36309 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36310 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36311 ret_ref = (uintptr_t)ret_var.inner;
36312 if (ret_var.is_owned) {
36313         ret_ref |= 1;
36314 }
36315         return ret_ref;
36316 }
36317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36318         LDKQueryChannelRange arg_conv;
36319         arg_conv.inner = (void*)(arg & (~1));
36320         arg_conv.is_owned = false;
36321         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36322         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
36323         return ret_conv;
36324 }
36325
36326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36327         LDKQueryChannelRange orig_conv;
36328         orig_conv.inner = (void*)(orig & (~1));
36329         orig_conv.is_owned = false;
36330         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36331         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
36332         int64_t ret_ref = 0;
36333         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36334         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36336         ret_ref = (uintptr_t)ret_var.inner;
36337         if (ret_var.is_owned) {
36338                 ret_ref |= 1;
36339         }
36340         return ret_ref;
36341 }
36342
36343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36344         LDKReplyChannelRange this_obj_conv;
36345         this_obj_conv.inner = (void*)(this_obj & (~1));
36346         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36348         ReplyChannelRange_free(this_obj_conv);
36349 }
36350
36351 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36352         LDKReplyChannelRange this_ptr_conv;
36353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36354         this_ptr_conv.is_owned = false;
36355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36356         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36357         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
36358         return ret_arr;
36359 }
36360
36361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36362         LDKReplyChannelRange this_ptr_conv;
36363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36364         this_ptr_conv.is_owned = false;
36365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36366         LDKThirtyTwoBytes val_ref;
36367         CHECK((*env)->GetArrayLength(env, val) == 32);
36368         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36369         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
36370 }
36371
36372 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
36373         LDKReplyChannelRange this_ptr_conv;
36374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36375         this_ptr_conv.is_owned = false;
36376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36377         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
36378         return ret_conv;
36379 }
36380
36381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36382         LDKReplyChannelRange this_ptr_conv;
36383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36384         this_ptr_conv.is_owned = false;
36385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36386         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
36387 }
36388
36389 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
36390         LDKReplyChannelRange this_ptr_conv;
36391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36392         this_ptr_conv.is_owned = false;
36393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36394         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
36395         return ret_conv;
36396 }
36397
36398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36399         LDKReplyChannelRange this_ptr_conv;
36400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36401         this_ptr_conv.is_owned = false;
36402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36403         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
36404 }
36405
36406 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
36407         LDKReplyChannelRange this_ptr_conv;
36408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36409         this_ptr_conv.is_owned = false;
36410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36411         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
36412         return ret_conv;
36413 }
36414
36415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
36416         LDKReplyChannelRange this_ptr_conv;
36417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36418         this_ptr_conv.is_owned = false;
36419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36420         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
36421 }
36422
36423 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
36424         LDKReplyChannelRange this_ptr_conv;
36425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36426         this_ptr_conv.is_owned = false;
36427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36428         LDKCVec_u64Z ret_var = ReplyChannelRange_get_short_channel_ids(&this_ptr_conv);
36429         int64_tArray ret_arr = NULL;
36430         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36431         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36432         for (size_t g = 0; g < ret_var.datalen; g++) {
36433                 int64_t ret_conv_6_conv = ret_var.data[g];
36434                 ret_arr_ptr[g] = ret_conv_6_conv;
36435         }
36436         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36437         FREE(ret_var.data);
36438         return ret_arr;
36439 }
36440
36441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36442         LDKReplyChannelRange this_ptr_conv;
36443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36444         this_ptr_conv.is_owned = false;
36445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36446         LDKCVec_u64Z val_constr;
36447         val_constr.datalen = (*env)->GetArrayLength(env, val);
36448         if (val_constr.datalen > 0)
36449                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36450         else
36451                 val_constr.data = NULL;
36452         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36453         for (size_t g = 0; g < val_constr.datalen; g++) {
36454                 int64_t val_conv_6 = val_vals[g];
36455                 val_constr.data[g] = val_conv_6;
36456         }
36457         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36458         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
36459 }
36460
36461 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) {
36462         LDKThirtyTwoBytes chain_hash_arg_ref;
36463         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36464         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36465         LDKCVec_u64Z short_channel_ids_arg_constr;
36466         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
36467         if (short_channel_ids_arg_constr.datalen > 0)
36468                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36469         else
36470                 short_channel_ids_arg_constr.data = NULL;
36471         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
36472         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
36473                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
36474                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
36475         }
36476         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
36477         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
36478         int64_t ret_ref = 0;
36479         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36480         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36482         ret_ref = (uintptr_t)ret_var.inner;
36483         if (ret_var.is_owned) {
36484                 ret_ref |= 1;
36485         }
36486         return ret_ref;
36487 }
36488
36489 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
36490         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
36491 int64_t ret_ref = 0;
36492 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36493 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36494 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36495 ret_ref = (uintptr_t)ret_var.inner;
36496 if (ret_var.is_owned) {
36497         ret_ref |= 1;
36498 }
36499         return ret_ref;
36500 }
36501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36502         LDKReplyChannelRange arg_conv;
36503         arg_conv.inner = (void*)(arg & (~1));
36504         arg_conv.is_owned = false;
36505         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36506         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
36507         return ret_conv;
36508 }
36509
36510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36511         LDKReplyChannelRange orig_conv;
36512         orig_conv.inner = (void*)(orig & (~1));
36513         orig_conv.is_owned = false;
36514         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36515         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
36516         int64_t ret_ref = 0;
36517         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36518         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36520         ret_ref = (uintptr_t)ret_var.inner;
36521         if (ret_var.is_owned) {
36522                 ret_ref |= 1;
36523         }
36524         return ret_ref;
36525 }
36526
36527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36528         LDKQueryShortChannelIds this_obj_conv;
36529         this_obj_conv.inner = (void*)(this_obj & (~1));
36530         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36532         QueryShortChannelIds_free(this_obj_conv);
36533 }
36534
36535 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36536         LDKQueryShortChannelIds this_ptr_conv;
36537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36538         this_ptr_conv.is_owned = false;
36539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36540         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36541         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
36542         return ret_arr;
36543 }
36544
36545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36546         LDKQueryShortChannelIds this_ptr_conv;
36547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36548         this_ptr_conv.is_owned = false;
36549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36550         LDKThirtyTwoBytes val_ref;
36551         CHECK((*env)->GetArrayLength(env, val) == 32);
36552         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36553         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
36554 }
36555
36556 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
36557         LDKQueryShortChannelIds this_ptr_conv;
36558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36559         this_ptr_conv.is_owned = false;
36560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36561         LDKCVec_u64Z ret_var = QueryShortChannelIds_get_short_channel_ids(&this_ptr_conv);
36562         int64_tArray ret_arr = NULL;
36563         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36564         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36565         for (size_t g = 0; g < ret_var.datalen; g++) {
36566                 int64_t ret_conv_6_conv = ret_var.data[g];
36567                 ret_arr_ptr[g] = ret_conv_6_conv;
36568         }
36569         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36570         FREE(ret_var.data);
36571         return ret_arr;
36572 }
36573
36574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36575         LDKQueryShortChannelIds this_ptr_conv;
36576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36577         this_ptr_conv.is_owned = false;
36578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36579         LDKCVec_u64Z val_constr;
36580         val_constr.datalen = (*env)->GetArrayLength(env, val);
36581         if (val_constr.datalen > 0)
36582                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36583         else
36584                 val_constr.data = NULL;
36585         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36586         for (size_t g = 0; g < val_constr.datalen; g++) {
36587                 int64_t val_conv_6 = val_vals[g];
36588                 val_constr.data[g] = val_conv_6;
36589         }
36590         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36591         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
36592 }
36593
36594 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) {
36595         LDKThirtyTwoBytes chain_hash_arg_ref;
36596         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36597         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36598         LDKCVec_u64Z short_channel_ids_arg_constr;
36599         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
36600         if (short_channel_ids_arg_constr.datalen > 0)
36601                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36602         else
36603                 short_channel_ids_arg_constr.data = NULL;
36604         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
36605         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
36606                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
36607                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
36608         }
36609         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
36610         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
36611         int64_t ret_ref = 0;
36612         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36613         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36615         ret_ref = (uintptr_t)ret_var.inner;
36616         if (ret_var.is_owned) {
36617                 ret_ref |= 1;
36618         }
36619         return ret_ref;
36620 }
36621
36622 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
36623         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
36624 int64_t ret_ref = 0;
36625 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36626 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36627 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36628 ret_ref = (uintptr_t)ret_var.inner;
36629 if (ret_var.is_owned) {
36630         ret_ref |= 1;
36631 }
36632         return ret_ref;
36633 }
36634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36635         LDKQueryShortChannelIds arg_conv;
36636         arg_conv.inner = (void*)(arg & (~1));
36637         arg_conv.is_owned = false;
36638         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36639         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
36640         return ret_conv;
36641 }
36642
36643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36644         LDKQueryShortChannelIds orig_conv;
36645         orig_conv.inner = (void*)(orig & (~1));
36646         orig_conv.is_owned = false;
36647         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36648         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
36649         int64_t ret_ref = 0;
36650         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36651         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36653         ret_ref = (uintptr_t)ret_var.inner;
36654         if (ret_var.is_owned) {
36655                 ret_ref |= 1;
36656         }
36657         return ret_ref;
36658 }
36659
36660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36661         LDKReplyShortChannelIdsEnd this_obj_conv;
36662         this_obj_conv.inner = (void*)(this_obj & (~1));
36663         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36665         ReplyShortChannelIdsEnd_free(this_obj_conv);
36666 }
36667
36668 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36669         LDKReplyShortChannelIdsEnd this_ptr_conv;
36670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36671         this_ptr_conv.is_owned = false;
36672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36673         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36674         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
36675         return ret_arr;
36676 }
36677
36678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36679         LDKReplyShortChannelIdsEnd this_ptr_conv;
36680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36681         this_ptr_conv.is_owned = false;
36682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36683         LDKThirtyTwoBytes val_ref;
36684         CHECK((*env)->GetArrayLength(env, val) == 32);
36685         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36686         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
36687 }
36688
36689 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
36690         LDKReplyShortChannelIdsEnd this_ptr_conv;
36691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36692         this_ptr_conv.is_owned = false;
36693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36694         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
36695         return ret_conv;
36696 }
36697
36698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
36699         LDKReplyShortChannelIdsEnd this_ptr_conv;
36700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36701         this_ptr_conv.is_owned = false;
36702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36703         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
36704 }
36705
36706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
36707         LDKThirtyTwoBytes chain_hash_arg_ref;
36708         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36709         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36710         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
36711         int64_t ret_ref = 0;
36712         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36713         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36715         ret_ref = (uintptr_t)ret_var.inner;
36716         if (ret_var.is_owned) {
36717                 ret_ref |= 1;
36718         }
36719         return ret_ref;
36720 }
36721
36722 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
36723         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
36724 int64_t ret_ref = 0;
36725 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36726 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36727 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36728 ret_ref = (uintptr_t)ret_var.inner;
36729 if (ret_var.is_owned) {
36730         ret_ref |= 1;
36731 }
36732         return ret_ref;
36733 }
36734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36735         LDKReplyShortChannelIdsEnd arg_conv;
36736         arg_conv.inner = (void*)(arg & (~1));
36737         arg_conv.is_owned = false;
36738         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36739         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
36740         return ret_conv;
36741 }
36742
36743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36744         LDKReplyShortChannelIdsEnd orig_conv;
36745         orig_conv.inner = (void*)(orig & (~1));
36746         orig_conv.is_owned = false;
36747         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36748         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
36749         int64_t ret_ref = 0;
36750         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36751         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36753         ret_ref = (uintptr_t)ret_var.inner;
36754         if (ret_var.is_owned) {
36755                 ret_ref |= 1;
36756         }
36757         return ret_ref;
36758 }
36759
36760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36761         LDKGossipTimestampFilter this_obj_conv;
36762         this_obj_conv.inner = (void*)(this_obj & (~1));
36763         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36765         GossipTimestampFilter_free(this_obj_conv);
36766 }
36767
36768 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36769         LDKGossipTimestampFilter this_ptr_conv;
36770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36771         this_ptr_conv.is_owned = false;
36772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36773         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36774         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
36775         return ret_arr;
36776 }
36777
36778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36779         LDKGossipTimestampFilter this_ptr_conv;
36780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36781         this_ptr_conv.is_owned = false;
36782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36783         LDKThirtyTwoBytes val_ref;
36784         CHECK((*env)->GetArrayLength(env, val) == 32);
36785         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36786         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
36787 }
36788
36789 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
36790         LDKGossipTimestampFilter this_ptr_conv;
36791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36792         this_ptr_conv.is_owned = false;
36793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36794         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
36795         return ret_conv;
36796 }
36797
36798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36799         LDKGossipTimestampFilter this_ptr_conv;
36800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36801         this_ptr_conv.is_owned = false;
36802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36803         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
36804 }
36805
36806 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
36807         LDKGossipTimestampFilter this_ptr_conv;
36808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36809         this_ptr_conv.is_owned = false;
36810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36811         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
36812         return ret_conv;
36813 }
36814
36815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36816         LDKGossipTimestampFilter this_ptr_conv;
36817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36818         this_ptr_conv.is_owned = false;
36819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36820         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
36821 }
36822
36823 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) {
36824         LDKThirtyTwoBytes chain_hash_arg_ref;
36825         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36826         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36827         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
36828         int64_t ret_ref = 0;
36829         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36830         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36832         ret_ref = (uintptr_t)ret_var.inner;
36833         if (ret_var.is_owned) {
36834                 ret_ref |= 1;
36835         }
36836         return ret_ref;
36837 }
36838
36839 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
36840         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
36841 int64_t ret_ref = 0;
36842 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36843 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36844 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36845 ret_ref = (uintptr_t)ret_var.inner;
36846 if (ret_var.is_owned) {
36847         ret_ref |= 1;
36848 }
36849         return ret_ref;
36850 }
36851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36852         LDKGossipTimestampFilter arg_conv;
36853         arg_conv.inner = (void*)(arg & (~1));
36854         arg_conv.is_owned = false;
36855         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36856         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
36857         return ret_conv;
36858 }
36859
36860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36861         LDKGossipTimestampFilter orig_conv;
36862         orig_conv.inner = (void*)(orig & (~1));
36863         orig_conv.is_owned = false;
36864         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36865         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
36866         int64_t ret_ref = 0;
36867         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36868         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36870         ret_ref = (uintptr_t)ret_var.inner;
36871         if (ret_var.is_owned) {
36872                 ret_ref |= 1;
36873         }
36874         return ret_ref;
36875 }
36876
36877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36878         if ((this_ptr & 1) != 0) return;
36879         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36880         CHECK_ACCESS(this_ptr_ptr);
36881         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
36882         FREE((void*)this_ptr);
36883         ErrorAction_free(this_ptr_conv);
36884 }
36885
36886 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
36887         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36888         *ret_copy = ErrorAction_clone(arg);
36889 int64_t ret_ref = (uintptr_t)ret_copy;
36890         return ret_ref;
36891 }
36892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36893         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
36894         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
36895         return ret_conv;
36896 }
36897
36898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36899         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
36900         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36901         *ret_copy = ErrorAction_clone(orig_conv);
36902         int64_t ret_ref = (uintptr_t)ret_copy;
36903         return ret_ref;
36904 }
36905
36906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
36907         LDKErrorMessage msg_conv;
36908         msg_conv.inner = (void*)(msg & (~1));
36909         msg_conv.is_owned = (msg & 1) || (msg == 0);
36910         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36911         msg_conv = ErrorMessage_clone(&msg_conv);
36912         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36913         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
36914         int64_t ret_ref = (uintptr_t)ret_copy;
36915         return ret_ref;
36916 }
36917
36918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
36919         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36920         *ret_copy = ErrorAction_ignore_error();
36921         int64_t ret_ref = (uintptr_t)ret_copy;
36922         return ret_ref;
36923 }
36924
36925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
36926         LDKLevel a_conv = LDKLevel_from_java(env, a);
36927         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36928         *ret_copy = ErrorAction_ignore_and_log(a_conv);
36929         int64_t ret_ref = (uintptr_t)ret_copy;
36930         return ret_ref;
36931 }
36932
36933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
36934         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36935         *ret_copy = ErrorAction_ignore_duplicate_gossip();
36936         int64_t ret_ref = (uintptr_t)ret_copy;
36937         return ret_ref;
36938 }
36939
36940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
36941         LDKErrorMessage msg_conv;
36942         msg_conv.inner = (void*)(msg & (~1));
36943         msg_conv.is_owned = (msg & 1) || (msg == 0);
36944         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36945         msg_conv = ErrorMessage_clone(&msg_conv);
36946         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36947         *ret_copy = ErrorAction_send_error_message(msg_conv);
36948         int64_t ret_ref = (uintptr_t)ret_copy;
36949         return ret_ref;
36950 }
36951
36952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
36953         LDKWarningMessage msg_conv;
36954         msg_conv.inner = (void*)(msg & (~1));
36955         msg_conv.is_owned = (msg & 1) || (msg == 0);
36956         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36957         msg_conv = WarningMessage_clone(&msg_conv);
36958         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
36959         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36960         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
36961         int64_t ret_ref = (uintptr_t)ret_copy;
36962         return ret_ref;
36963 }
36964
36965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36966         LDKLightningError this_obj_conv;
36967         this_obj_conv.inner = (void*)(this_obj & (~1));
36968         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36970         LightningError_free(this_obj_conv);
36971 }
36972
36973 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
36974         LDKLightningError this_ptr_conv;
36975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36976         this_ptr_conv.is_owned = false;
36977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36978         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
36979         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
36980         Str_free(ret_str);
36981         return ret_conv;
36982 }
36983
36984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
36985         LDKLightningError this_ptr_conv;
36986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36987         this_ptr_conv.is_owned = false;
36988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36989         LDKStr val_conv = java_to_owned_str(env, val);
36990         LightningError_set_err(&this_ptr_conv, val_conv);
36991 }
36992
36993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
36994         LDKLightningError this_ptr_conv;
36995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36996         this_ptr_conv.is_owned = false;
36997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36998         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36999         *ret_copy = LightningError_get_action(&this_ptr_conv);
37000         int64_t ret_ref = (uintptr_t)ret_copy;
37001         return ret_ref;
37002 }
37003
37004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37005         LDKLightningError this_ptr_conv;
37006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37007         this_ptr_conv.is_owned = false;
37008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37009         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
37010         CHECK_ACCESS(val_ptr);
37011         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
37012         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
37013         LightningError_set_action(&this_ptr_conv, val_conv);
37014 }
37015
37016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
37017         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
37018         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
37019         CHECK_ACCESS(action_arg_ptr);
37020         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
37021         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
37022         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
37023         int64_t ret_ref = 0;
37024         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37025         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37026         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37027         ret_ref = (uintptr_t)ret_var.inner;
37028         if (ret_var.is_owned) {
37029                 ret_ref |= 1;
37030         }
37031         return ret_ref;
37032 }
37033
37034 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
37035         LDKLightningError ret_var = LightningError_clone(arg);
37036 int64_t ret_ref = 0;
37037 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37038 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37039 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37040 ret_ref = (uintptr_t)ret_var.inner;
37041 if (ret_var.is_owned) {
37042         ret_ref |= 1;
37043 }
37044         return ret_ref;
37045 }
37046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37047         LDKLightningError arg_conv;
37048         arg_conv.inner = (void*)(arg & (~1));
37049         arg_conv.is_owned = false;
37050         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37051         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
37052         return ret_conv;
37053 }
37054
37055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37056         LDKLightningError orig_conv;
37057         orig_conv.inner = (void*)(orig & (~1));
37058         orig_conv.is_owned = false;
37059         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37060         LDKLightningError ret_var = LightningError_clone(&orig_conv);
37061         int64_t ret_ref = 0;
37062         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37063         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37065         ret_ref = (uintptr_t)ret_var.inner;
37066         if (ret_var.is_owned) {
37067                 ret_ref |= 1;
37068         }
37069         return ret_ref;
37070 }
37071
37072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37073         LDKCommitmentUpdate this_obj_conv;
37074         this_obj_conv.inner = (void*)(this_obj & (~1));
37075         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37077         CommitmentUpdate_free(this_obj_conv);
37078 }
37079
37080 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
37081         LDKCommitmentUpdate this_ptr_conv;
37082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37083         this_ptr_conv.is_owned = false;
37084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37085         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
37086         int64_tArray ret_arr = NULL;
37087         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37088         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37089         for (size_t p = 0; p < ret_var.datalen; p++) {
37090                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
37091                 int64_t ret_conv_15_ref = 0;
37092                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37093                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37094                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
37095                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
37096                 if (ret_conv_15_var.is_owned) {
37097                         ret_conv_15_ref |= 1;
37098                 }
37099                 ret_arr_ptr[p] = ret_conv_15_ref;
37100         }
37101         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37102         FREE(ret_var.data);
37103         return ret_arr;
37104 }
37105
37106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37107         LDKCommitmentUpdate this_ptr_conv;
37108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37109         this_ptr_conv.is_owned = false;
37110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37111         LDKCVec_UpdateAddHTLCZ val_constr;
37112         val_constr.datalen = (*env)->GetArrayLength(env, val);
37113         if (val_constr.datalen > 0)
37114                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
37115         else
37116                 val_constr.data = NULL;
37117         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37118         for (size_t p = 0; p < val_constr.datalen; p++) {
37119                 int64_t val_conv_15 = val_vals[p];
37120                 LDKUpdateAddHTLC val_conv_15_conv;
37121                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
37122                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
37123                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
37124                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
37125                 val_constr.data[p] = val_conv_15_conv;
37126         }
37127         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37128         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
37129 }
37130
37131 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
37132         LDKCommitmentUpdate this_ptr_conv;
37133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37134         this_ptr_conv.is_owned = false;
37135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37136         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
37137         int64_tArray ret_arr = NULL;
37138         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37139         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37140         for (size_t t = 0; t < ret_var.datalen; t++) {
37141                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
37142                 int64_t ret_conv_19_ref = 0;
37143                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37144                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37145                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
37146                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
37147                 if (ret_conv_19_var.is_owned) {
37148                         ret_conv_19_ref |= 1;
37149                 }
37150                 ret_arr_ptr[t] = ret_conv_19_ref;
37151         }
37152         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37153         FREE(ret_var.data);
37154         return ret_arr;
37155 }
37156
37157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37158         LDKCommitmentUpdate this_ptr_conv;
37159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37160         this_ptr_conv.is_owned = false;
37161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37162         LDKCVec_UpdateFulfillHTLCZ val_constr;
37163         val_constr.datalen = (*env)->GetArrayLength(env, val);
37164         if (val_constr.datalen > 0)
37165                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
37166         else
37167                 val_constr.data = NULL;
37168         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37169         for (size_t t = 0; t < val_constr.datalen; t++) {
37170                 int64_t val_conv_19 = val_vals[t];
37171                 LDKUpdateFulfillHTLC val_conv_19_conv;
37172                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
37173                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
37174                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
37175                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
37176                 val_constr.data[t] = val_conv_19_conv;
37177         }
37178         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37179         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
37180 }
37181
37182 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
37183         LDKCommitmentUpdate this_ptr_conv;
37184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37185         this_ptr_conv.is_owned = false;
37186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37187         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
37188         int64_tArray ret_arr = NULL;
37189         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37190         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37191         for (size_t q = 0; q < ret_var.datalen; q++) {
37192                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
37193                 int64_t ret_conv_16_ref = 0;
37194                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37195                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37196                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
37197                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
37198                 if (ret_conv_16_var.is_owned) {
37199                         ret_conv_16_ref |= 1;
37200                 }
37201                 ret_arr_ptr[q] = ret_conv_16_ref;
37202         }
37203         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37204         FREE(ret_var.data);
37205         return ret_arr;
37206 }
37207
37208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37209         LDKCommitmentUpdate this_ptr_conv;
37210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37211         this_ptr_conv.is_owned = false;
37212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37213         LDKCVec_UpdateFailHTLCZ val_constr;
37214         val_constr.datalen = (*env)->GetArrayLength(env, val);
37215         if (val_constr.datalen > 0)
37216                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
37217         else
37218                 val_constr.data = NULL;
37219         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37220         for (size_t q = 0; q < val_constr.datalen; q++) {
37221                 int64_t val_conv_16 = val_vals[q];
37222                 LDKUpdateFailHTLC val_conv_16_conv;
37223                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
37224                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
37225                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
37226                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
37227                 val_constr.data[q] = val_conv_16_conv;
37228         }
37229         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37230         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
37231 }
37232
37233 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
37234         LDKCommitmentUpdate this_ptr_conv;
37235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37236         this_ptr_conv.is_owned = false;
37237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37238         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
37239         int64_tArray ret_arr = NULL;
37240         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37241         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37242         for (size_t z = 0; z < ret_var.datalen; z++) {
37243                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
37244                 int64_t ret_conv_25_ref = 0;
37245                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37246                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37247                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
37248                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
37249                 if (ret_conv_25_var.is_owned) {
37250                         ret_conv_25_ref |= 1;
37251                 }
37252                 ret_arr_ptr[z] = ret_conv_25_ref;
37253         }
37254         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37255         FREE(ret_var.data);
37256         return ret_arr;
37257 }
37258
37259 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) {
37260         LDKCommitmentUpdate this_ptr_conv;
37261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37262         this_ptr_conv.is_owned = false;
37263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37264         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
37265         val_constr.datalen = (*env)->GetArrayLength(env, val);
37266         if (val_constr.datalen > 0)
37267                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
37268         else
37269                 val_constr.data = NULL;
37270         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37271         for (size_t z = 0; z < val_constr.datalen; z++) {
37272                 int64_t val_conv_25 = val_vals[z];
37273                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
37274                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
37275                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
37276                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
37277                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
37278                 val_constr.data[z] = val_conv_25_conv;
37279         }
37280         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37281         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
37282 }
37283
37284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
37285         LDKCommitmentUpdate this_ptr_conv;
37286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37287         this_ptr_conv.is_owned = false;
37288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37289         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
37290         int64_t ret_ref = 0;
37291         if ((uintptr_t)ret_var.inner > 4096) {
37292                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37293                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37295                 ret_ref = (uintptr_t)ret_var.inner;
37296                 if (ret_var.is_owned) {
37297                         ret_ref |= 1;
37298                 }
37299         }
37300         return ret_ref;
37301 }
37302
37303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37304         LDKCommitmentUpdate this_ptr_conv;
37305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37306         this_ptr_conv.is_owned = false;
37307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37308         LDKUpdateFee val_conv;
37309         val_conv.inner = (void*)(val & (~1));
37310         val_conv.is_owned = (val & 1) || (val == 0);
37311         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37312         val_conv = UpdateFee_clone(&val_conv);
37313         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
37314 }
37315
37316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
37317         LDKCommitmentUpdate this_ptr_conv;
37318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37319         this_ptr_conv.is_owned = false;
37320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37321         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
37322         int64_t ret_ref = 0;
37323         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37324         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37325         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37326         ret_ref = (uintptr_t)ret_var.inner;
37327         if (ret_var.is_owned) {
37328                 ret_ref |= 1;
37329         }
37330         return ret_ref;
37331 }
37332
37333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37334         LDKCommitmentUpdate this_ptr_conv;
37335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37336         this_ptr_conv.is_owned = false;
37337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37338         LDKCommitmentSigned val_conv;
37339         val_conv.inner = (void*)(val & (~1));
37340         val_conv.is_owned = (val & 1) || (val == 0);
37341         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37342         val_conv = CommitmentSigned_clone(&val_conv);
37343         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
37344 }
37345
37346 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) {
37347         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
37348         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
37349         if (update_add_htlcs_arg_constr.datalen > 0)
37350                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
37351         else
37352                 update_add_htlcs_arg_constr.data = NULL;
37353         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
37354         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
37355                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
37356                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
37357                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
37358                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
37359                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
37360                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
37361                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
37362         }
37363         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
37364         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
37365         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
37366         if (update_fulfill_htlcs_arg_constr.datalen > 0)
37367                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
37368         else
37369                 update_fulfill_htlcs_arg_constr.data = NULL;
37370         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
37371         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
37372                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
37373                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
37374                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
37375                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
37376                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
37377                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
37378                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
37379         }
37380         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
37381         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
37382         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
37383         if (update_fail_htlcs_arg_constr.datalen > 0)
37384                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
37385         else
37386                 update_fail_htlcs_arg_constr.data = NULL;
37387         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
37388         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
37389                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
37390                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
37391                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
37392                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
37393                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
37394                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
37395                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
37396         }
37397         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
37398         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
37399         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
37400         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
37401                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
37402         else
37403                 update_fail_malformed_htlcs_arg_constr.data = NULL;
37404         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
37405         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
37406                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
37407                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
37408                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
37409                 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);
37410                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
37411                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
37412                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
37413         }
37414         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
37415         LDKUpdateFee update_fee_arg_conv;
37416         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
37417         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
37418         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
37419         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
37420         LDKCommitmentSigned commitment_signed_arg_conv;
37421         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
37422         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
37423         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
37424         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
37425         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);
37426         int64_t ret_ref = 0;
37427         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37428         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37430         ret_ref = (uintptr_t)ret_var.inner;
37431         if (ret_var.is_owned) {
37432                 ret_ref |= 1;
37433         }
37434         return ret_ref;
37435 }
37436
37437 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
37438         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
37439 int64_t ret_ref = 0;
37440 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37441 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37442 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37443 ret_ref = (uintptr_t)ret_var.inner;
37444 if (ret_var.is_owned) {
37445         ret_ref |= 1;
37446 }
37447         return ret_ref;
37448 }
37449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37450         LDKCommitmentUpdate arg_conv;
37451         arg_conv.inner = (void*)(arg & (~1));
37452         arg_conv.is_owned = false;
37453         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37454         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
37455         return ret_conv;
37456 }
37457
37458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37459         LDKCommitmentUpdate orig_conv;
37460         orig_conv.inner = (void*)(orig & (~1));
37461         orig_conv.is_owned = false;
37462         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37463         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
37464         int64_t ret_ref = 0;
37465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37468         ret_ref = (uintptr_t)ret_var.inner;
37469         if (ret_var.is_owned) {
37470                 ret_ref |= 1;
37471         }
37472         return ret_ref;
37473 }
37474
37475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37476         if ((this_ptr & 1) != 0) return;
37477         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37478         CHECK_ACCESS(this_ptr_ptr);
37479         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
37480         FREE((void*)this_ptr);
37481         ChannelMessageHandler_free(this_ptr_conv);
37482 }
37483
37484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37485         if ((this_ptr & 1) != 0) return;
37486         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37487         CHECK_ACCESS(this_ptr_ptr);
37488         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
37489         FREE((void*)this_ptr);
37490         RoutingMessageHandler_free(this_ptr_conv);
37491 }
37492
37493 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
37494         LDKAcceptChannel obj_conv;
37495         obj_conv.inner = (void*)(obj & (~1));
37496         obj_conv.is_owned = false;
37497         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37498         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
37499         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37500         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37501         CVec_u8Z_free(ret_var);
37502         return ret_arr;
37503 }
37504
37505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37506         LDKu8slice ser_ref;
37507         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37508         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37509         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
37510         *ret_conv = AcceptChannel_read(ser_ref);
37511         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37512         return (int64_t)ret_conv;
37513 }
37514
37515 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
37516         LDKAnnouncementSignatures obj_conv;
37517         obj_conv.inner = (void*)(obj & (~1));
37518         obj_conv.is_owned = false;
37519         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37520         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
37521         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37522         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37523         CVec_u8Z_free(ret_var);
37524         return ret_arr;
37525 }
37526
37527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37528         LDKu8slice ser_ref;
37529         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37530         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37531         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
37532         *ret_conv = AnnouncementSignatures_read(ser_ref);
37533         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37534         return (int64_t)ret_conv;
37535 }
37536
37537 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
37538         LDKChannelReestablish obj_conv;
37539         obj_conv.inner = (void*)(obj & (~1));
37540         obj_conv.is_owned = false;
37541         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37542         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
37543         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37544         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37545         CVec_u8Z_free(ret_var);
37546         return ret_arr;
37547 }
37548
37549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37550         LDKu8slice ser_ref;
37551         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37552         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37553         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
37554         *ret_conv = ChannelReestablish_read(ser_ref);
37555         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37556         return (int64_t)ret_conv;
37557 }
37558
37559 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
37560         LDKClosingSigned obj_conv;
37561         obj_conv.inner = (void*)(obj & (~1));
37562         obj_conv.is_owned = false;
37563         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37564         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
37565         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37566         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37567         CVec_u8Z_free(ret_var);
37568         return ret_arr;
37569 }
37570
37571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37572         LDKu8slice ser_ref;
37573         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37574         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37575         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
37576         *ret_conv = ClosingSigned_read(ser_ref);
37577         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37578         return (int64_t)ret_conv;
37579 }
37580
37581 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
37582         LDKClosingSignedFeeRange obj_conv;
37583         obj_conv.inner = (void*)(obj & (~1));
37584         obj_conv.is_owned = false;
37585         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37586         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
37587         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37588         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37589         CVec_u8Z_free(ret_var);
37590         return ret_arr;
37591 }
37592
37593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37594         LDKu8slice ser_ref;
37595         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37596         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37597         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
37598         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
37599         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37600         return (int64_t)ret_conv;
37601 }
37602
37603 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
37604         LDKCommitmentSigned obj_conv;
37605         obj_conv.inner = (void*)(obj & (~1));
37606         obj_conv.is_owned = false;
37607         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37608         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
37609         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37610         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37611         CVec_u8Z_free(ret_var);
37612         return ret_arr;
37613 }
37614
37615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37616         LDKu8slice ser_ref;
37617         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37618         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37619         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
37620         *ret_conv = CommitmentSigned_read(ser_ref);
37621         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37622         return (int64_t)ret_conv;
37623 }
37624
37625 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
37626         LDKFundingCreated obj_conv;
37627         obj_conv.inner = (void*)(obj & (~1));
37628         obj_conv.is_owned = false;
37629         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37630         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
37631         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37632         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37633         CVec_u8Z_free(ret_var);
37634         return ret_arr;
37635 }
37636
37637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37638         LDKu8slice ser_ref;
37639         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37640         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37641         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
37642         *ret_conv = FundingCreated_read(ser_ref);
37643         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37644         return (int64_t)ret_conv;
37645 }
37646
37647 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
37648         LDKFundingSigned obj_conv;
37649         obj_conv.inner = (void*)(obj & (~1));
37650         obj_conv.is_owned = false;
37651         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37652         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
37653         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37654         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37655         CVec_u8Z_free(ret_var);
37656         return ret_arr;
37657 }
37658
37659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37660         LDKu8slice ser_ref;
37661         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37662         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37663         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
37664         *ret_conv = FundingSigned_read(ser_ref);
37665         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37666         return (int64_t)ret_conv;
37667 }
37668
37669 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1write(JNIEnv *env, jclass clz, int64_t obj) {
37670         LDKChannelReady obj_conv;
37671         obj_conv.inner = (void*)(obj & (~1));
37672         obj_conv.is_owned = false;
37673         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37674         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
37675         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37676         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37677         CVec_u8Z_free(ret_var);
37678         return ret_arr;
37679 }
37680
37681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37682         LDKu8slice ser_ref;
37683         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37684         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37685         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
37686         *ret_conv = ChannelReady_read(ser_ref);
37687         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37688         return (int64_t)ret_conv;
37689 }
37690
37691 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
37692         LDKInit obj_conv;
37693         obj_conv.inner = (void*)(obj & (~1));
37694         obj_conv.is_owned = false;
37695         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37696         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
37697         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37698         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37699         CVec_u8Z_free(ret_var);
37700         return ret_arr;
37701 }
37702
37703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37704         LDKu8slice ser_ref;
37705         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37706         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37707         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
37708         *ret_conv = Init_read(ser_ref);
37709         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37710         return (int64_t)ret_conv;
37711 }
37712
37713 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
37714         LDKOpenChannel obj_conv;
37715         obj_conv.inner = (void*)(obj & (~1));
37716         obj_conv.is_owned = false;
37717         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37718         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
37719         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37720         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37721         CVec_u8Z_free(ret_var);
37722         return ret_arr;
37723 }
37724
37725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37726         LDKu8slice ser_ref;
37727         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37728         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37729         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
37730         *ret_conv = OpenChannel_read(ser_ref);
37731         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37732         return (int64_t)ret_conv;
37733 }
37734
37735 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
37736         LDKRevokeAndACK obj_conv;
37737         obj_conv.inner = (void*)(obj & (~1));
37738         obj_conv.is_owned = false;
37739         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37740         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
37741         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37742         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37743         CVec_u8Z_free(ret_var);
37744         return ret_arr;
37745 }
37746
37747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37748         LDKu8slice ser_ref;
37749         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37750         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37751         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
37752         *ret_conv = RevokeAndACK_read(ser_ref);
37753         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37754         return (int64_t)ret_conv;
37755 }
37756
37757 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
37758         LDKShutdown obj_conv;
37759         obj_conv.inner = (void*)(obj & (~1));
37760         obj_conv.is_owned = false;
37761         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37762         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
37763         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37764         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37765         CVec_u8Z_free(ret_var);
37766         return ret_arr;
37767 }
37768
37769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37770         LDKu8slice ser_ref;
37771         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37772         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37773         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
37774         *ret_conv = Shutdown_read(ser_ref);
37775         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37776         return (int64_t)ret_conv;
37777 }
37778
37779 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37780         LDKUpdateFailHTLC obj_conv;
37781         obj_conv.inner = (void*)(obj & (~1));
37782         obj_conv.is_owned = false;
37783         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37784         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
37785         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37786         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37787         CVec_u8Z_free(ret_var);
37788         return ret_arr;
37789 }
37790
37791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37792         LDKu8slice ser_ref;
37793         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37794         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37795         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
37796         *ret_conv = UpdateFailHTLC_read(ser_ref);
37797         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37798         return (int64_t)ret_conv;
37799 }
37800
37801 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37802         LDKUpdateFailMalformedHTLC obj_conv;
37803         obj_conv.inner = (void*)(obj & (~1));
37804         obj_conv.is_owned = false;
37805         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37806         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
37807         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37808         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37809         CVec_u8Z_free(ret_var);
37810         return ret_arr;
37811 }
37812
37813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37814         LDKu8slice ser_ref;
37815         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37816         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37817         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
37818         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
37819         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37820         return (int64_t)ret_conv;
37821 }
37822
37823 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
37824         LDKUpdateFee obj_conv;
37825         obj_conv.inner = (void*)(obj & (~1));
37826         obj_conv.is_owned = false;
37827         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37828         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
37829         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37830         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37831         CVec_u8Z_free(ret_var);
37832         return ret_arr;
37833 }
37834
37835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37836         LDKu8slice ser_ref;
37837         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37838         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37839         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
37840         *ret_conv = UpdateFee_read(ser_ref);
37841         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37842         return (int64_t)ret_conv;
37843 }
37844
37845 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37846         LDKUpdateFulfillHTLC obj_conv;
37847         obj_conv.inner = (void*)(obj & (~1));
37848         obj_conv.is_owned = false;
37849         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37850         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
37851         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37852         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37853         CVec_u8Z_free(ret_var);
37854         return ret_arr;
37855 }
37856
37857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37858         LDKu8slice ser_ref;
37859         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37860         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37861         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
37862         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
37863         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37864         return (int64_t)ret_conv;
37865 }
37866
37867 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37868         LDKUpdateAddHTLC obj_conv;
37869         obj_conv.inner = (void*)(obj & (~1));
37870         obj_conv.is_owned = false;
37871         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37872         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
37873         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37874         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37875         CVec_u8Z_free(ret_var);
37876         return ret_arr;
37877 }
37878
37879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37880         LDKu8slice ser_ref;
37881         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37882         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37883         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
37884         *ret_conv = UpdateAddHTLC_read(ser_ref);
37885         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37886         return (int64_t)ret_conv;
37887 }
37888
37889 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
37890         LDKPing obj_conv;
37891         obj_conv.inner = (void*)(obj & (~1));
37892         obj_conv.is_owned = false;
37893         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37894         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
37895         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37896         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37897         CVec_u8Z_free(ret_var);
37898         return ret_arr;
37899 }
37900
37901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37902         LDKu8slice ser_ref;
37903         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37904         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37905         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
37906         *ret_conv = Ping_read(ser_ref);
37907         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37908         return (int64_t)ret_conv;
37909 }
37910
37911 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
37912         LDKPong obj_conv;
37913         obj_conv.inner = (void*)(obj & (~1));
37914         obj_conv.is_owned = false;
37915         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37916         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
37917         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37918         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37919         CVec_u8Z_free(ret_var);
37920         return ret_arr;
37921 }
37922
37923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37924         LDKu8slice ser_ref;
37925         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37926         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37927         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
37928         *ret_conv = Pong_read(ser_ref);
37929         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37930         return (int64_t)ret_conv;
37931 }
37932
37933 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37934         LDKUnsignedChannelAnnouncement obj_conv;
37935         obj_conv.inner = (void*)(obj & (~1));
37936         obj_conv.is_owned = false;
37937         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37938         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
37939         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37940         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37941         CVec_u8Z_free(ret_var);
37942         return ret_arr;
37943 }
37944
37945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37946         LDKu8slice ser_ref;
37947         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37948         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37949         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
37950         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
37951         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37952         return (int64_t)ret_conv;
37953 }
37954
37955 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37956         LDKChannelAnnouncement obj_conv;
37957         obj_conv.inner = (void*)(obj & (~1));
37958         obj_conv.is_owned = false;
37959         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37960         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
37961         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37962         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37963         CVec_u8Z_free(ret_var);
37964         return ret_arr;
37965 }
37966
37967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37968         LDKu8slice ser_ref;
37969         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37970         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37971         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
37972         *ret_conv = ChannelAnnouncement_read(ser_ref);
37973         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37974         return (int64_t)ret_conv;
37975 }
37976
37977 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
37978         LDKUnsignedChannelUpdate obj_conv;
37979         obj_conv.inner = (void*)(obj & (~1));
37980         obj_conv.is_owned = false;
37981         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37982         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
37983         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37984         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37985         CVec_u8Z_free(ret_var);
37986         return ret_arr;
37987 }
37988
37989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37990         LDKu8slice ser_ref;
37991         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37992         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37993         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
37994         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
37995         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37996         return (int64_t)ret_conv;
37997 }
37998
37999 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
38000         LDKChannelUpdate obj_conv;
38001         obj_conv.inner = (void*)(obj & (~1));
38002         obj_conv.is_owned = false;
38003         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38004         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
38005         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38006         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38007         CVec_u8Z_free(ret_var);
38008         return ret_arr;
38009 }
38010
38011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38012         LDKu8slice ser_ref;
38013         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38014         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38015         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
38016         *ret_conv = ChannelUpdate_read(ser_ref);
38017         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38018         return (int64_t)ret_conv;
38019 }
38020
38021 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
38022         LDKErrorMessage obj_conv;
38023         obj_conv.inner = (void*)(obj & (~1));
38024         obj_conv.is_owned = false;
38025         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38026         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
38027         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38028         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38029         CVec_u8Z_free(ret_var);
38030         return ret_arr;
38031 }
38032
38033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38034         LDKu8slice ser_ref;
38035         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38036         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38037         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
38038         *ret_conv = ErrorMessage_read(ser_ref);
38039         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38040         return (int64_t)ret_conv;
38041 }
38042
38043 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
38044         LDKWarningMessage obj_conv;
38045         obj_conv.inner = (void*)(obj & (~1));
38046         obj_conv.is_owned = false;
38047         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38048         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
38049         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38050         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38051         CVec_u8Z_free(ret_var);
38052         return ret_arr;
38053 }
38054
38055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38056         LDKu8slice ser_ref;
38057         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38058         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38059         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
38060         *ret_conv = WarningMessage_read(ser_ref);
38061         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38062         return (int64_t)ret_conv;
38063 }
38064
38065 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
38066         LDKUnsignedNodeAnnouncement obj_conv;
38067         obj_conv.inner = (void*)(obj & (~1));
38068         obj_conv.is_owned = false;
38069         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38070         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
38071         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38072         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38073         CVec_u8Z_free(ret_var);
38074         return ret_arr;
38075 }
38076
38077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38078         LDKu8slice ser_ref;
38079         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38080         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38081         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
38082         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
38083         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38084         return (int64_t)ret_conv;
38085 }
38086
38087 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
38088         LDKNodeAnnouncement obj_conv;
38089         obj_conv.inner = (void*)(obj & (~1));
38090         obj_conv.is_owned = false;
38091         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38092         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
38093         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38094         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38095         CVec_u8Z_free(ret_var);
38096         return ret_arr;
38097 }
38098
38099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38100         LDKu8slice ser_ref;
38101         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38102         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38103         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
38104         *ret_conv = NodeAnnouncement_read(ser_ref);
38105         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38106         return (int64_t)ret_conv;
38107 }
38108
38109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38110         LDKu8slice ser_ref;
38111         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38112         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38113         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
38114         *ret_conv = QueryShortChannelIds_read(ser_ref);
38115         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38116         return (int64_t)ret_conv;
38117 }
38118
38119 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
38120         LDKQueryShortChannelIds obj_conv;
38121         obj_conv.inner = (void*)(obj & (~1));
38122         obj_conv.is_owned = false;
38123         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38124         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
38125         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38126         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38127         CVec_u8Z_free(ret_var);
38128         return ret_arr;
38129 }
38130
38131 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
38132         LDKReplyShortChannelIdsEnd obj_conv;
38133         obj_conv.inner = (void*)(obj & (~1));
38134         obj_conv.is_owned = false;
38135         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38136         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
38137         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38138         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38139         CVec_u8Z_free(ret_var);
38140         return ret_arr;
38141 }
38142
38143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38144         LDKu8slice ser_ref;
38145         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38146         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38147         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
38148         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
38149         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38150         return (int64_t)ret_conv;
38151 }
38152
38153 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
38154         LDKQueryChannelRange this_arg_conv;
38155         this_arg_conv.inner = (void*)(this_arg & (~1));
38156         this_arg_conv.is_owned = false;
38157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38158         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
38159         return ret_conv;
38160 }
38161
38162 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
38163         LDKQueryChannelRange obj_conv;
38164         obj_conv.inner = (void*)(obj & (~1));
38165         obj_conv.is_owned = false;
38166         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38167         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
38168         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38169         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38170         CVec_u8Z_free(ret_var);
38171         return ret_arr;
38172 }
38173
38174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38175         LDKu8slice ser_ref;
38176         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38177         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38178         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
38179         *ret_conv = QueryChannelRange_read(ser_ref);
38180         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38181         return (int64_t)ret_conv;
38182 }
38183
38184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38185         LDKu8slice ser_ref;
38186         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38187         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38188         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
38189         *ret_conv = ReplyChannelRange_read(ser_ref);
38190         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38191         return (int64_t)ret_conv;
38192 }
38193
38194 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
38195         LDKReplyChannelRange obj_conv;
38196         obj_conv.inner = (void*)(obj & (~1));
38197         obj_conv.is_owned = false;
38198         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38199         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
38200         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38201         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38202         CVec_u8Z_free(ret_var);
38203         return ret_arr;
38204 }
38205
38206 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
38207         LDKGossipTimestampFilter obj_conv;
38208         obj_conv.inner = (void*)(obj & (~1));
38209         obj_conv.is_owned = false;
38210         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38211         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
38212         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38213         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38214         CVec_u8Z_free(ret_var);
38215         return ret_arr;
38216 }
38217
38218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38219         LDKu8slice ser_ref;
38220         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38221         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38222         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
38223         *ret_conv = GossipTimestampFilter_read(ser_ref);
38224         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38225         return (int64_t)ret_conv;
38226 }
38227
38228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38229         if ((this_ptr & 1) != 0) return;
38230         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38231         CHECK_ACCESS(this_ptr_ptr);
38232         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
38233         FREE((void*)this_ptr);
38234         CustomMessageHandler_free(this_ptr_conv);
38235 }
38236
38237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38238         LDKIgnoringMessageHandler this_obj_conv;
38239         this_obj_conv.inner = (void*)(this_obj & (~1));
38240         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38242         IgnoringMessageHandler_free(this_obj_conv);
38243 }
38244
38245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
38246         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
38247         int64_t ret_ref = 0;
38248         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38249         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38250         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38251         ret_ref = (uintptr_t)ret_var.inner;
38252         if (ret_var.is_owned) {
38253                 ret_ref |= 1;
38254         }
38255         return ret_ref;
38256 }
38257
38258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
38259         LDKIgnoringMessageHandler this_arg_conv;
38260         this_arg_conv.inner = (void*)(this_arg & (~1));
38261         this_arg_conv.is_owned = false;
38262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38263         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
38264         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
38265         return (int64_t)ret_ret;
38266 }
38267
38268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
38269         LDKIgnoringMessageHandler this_arg_conv;
38270         this_arg_conv.inner = (void*)(this_arg & (~1));
38271         this_arg_conv.is_owned = false;
38272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38273         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
38274         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
38275         return (int64_t)ret_ret;
38276 }
38277
38278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
38279         LDKIgnoringMessageHandler this_arg_conv;
38280         this_arg_conv.inner = (void*)(this_arg & (~1));
38281         this_arg_conv.is_owned = false;
38282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38283         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
38284         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
38285         return (int64_t)ret_ret;
38286 }
38287
38288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
38289         LDKIgnoringMessageHandler this_arg_conv;
38290         this_arg_conv.inner = (void*)(this_arg & (~1));
38291         this_arg_conv.is_owned = false;
38292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38293         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
38294         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
38295         return (int64_t)ret_ret;
38296 }
38297
38298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38299         LDKErroringMessageHandler this_obj_conv;
38300         this_obj_conv.inner = (void*)(this_obj & (~1));
38301         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38303         ErroringMessageHandler_free(this_obj_conv);
38304 }
38305
38306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
38307         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
38308         int64_t ret_ref = 0;
38309         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38310         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38312         ret_ref = (uintptr_t)ret_var.inner;
38313         if (ret_var.is_owned) {
38314                 ret_ref |= 1;
38315         }
38316         return ret_ref;
38317 }
38318
38319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
38320         LDKErroringMessageHandler this_arg_conv;
38321         this_arg_conv.inner = (void*)(this_arg & (~1));
38322         this_arg_conv.is_owned = false;
38323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38324         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
38325         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
38326         return (int64_t)ret_ret;
38327 }
38328
38329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
38330         LDKErroringMessageHandler this_arg_conv;
38331         this_arg_conv.inner = (void*)(this_arg & (~1));
38332         this_arg_conv.is_owned = false;
38333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38334         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
38335         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
38336         return (int64_t)ret_ret;
38337 }
38338
38339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38340         LDKMessageHandler this_obj_conv;
38341         this_obj_conv.inner = (void*)(this_obj & (~1));
38342         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38344         MessageHandler_free(this_obj_conv);
38345 }
38346
38347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
38348         LDKMessageHandler this_ptr_conv;
38349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38350         this_ptr_conv.is_owned = false;
38351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38352         // WARNING: This object doesn't live past this scope, needs clone!
38353         int64_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
38354         return ret_ret;
38355 }
38356
38357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38358         LDKMessageHandler this_ptr_conv;
38359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38360         this_ptr_conv.is_owned = false;
38361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38362         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38363         CHECK_ACCESS(val_ptr);
38364         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
38365         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
38366                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38367                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
38368         }
38369         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
38370 }
38371
38372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
38373         LDKMessageHandler this_ptr_conv;
38374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38375         this_ptr_conv.is_owned = false;
38376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38377         // WARNING: This object doesn't live past this scope, needs clone!
38378         int64_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
38379         return ret_ret;
38380 }
38381
38382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38383         LDKMessageHandler this_ptr_conv;
38384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38385         this_ptr_conv.is_owned = false;
38386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38387         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38388         CHECK_ACCESS(val_ptr);
38389         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
38390         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
38391                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38392                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
38393         }
38394         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
38395 }
38396
38397 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) {
38398         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
38399         CHECK_ACCESS(chan_handler_arg_ptr);
38400         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
38401         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
38402                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38403                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
38404         }
38405         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
38406         CHECK_ACCESS(route_handler_arg_ptr);
38407         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
38408         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
38409                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38410                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
38411         }
38412         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
38413         int64_t ret_ref = 0;
38414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38417         ret_ref = (uintptr_t)ret_var.inner;
38418         if (ret_var.is_owned) {
38419                 ret_ref |= 1;
38420         }
38421         return ret_ref;
38422 }
38423
38424 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
38425         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
38426         *ret_ret = SocketDescriptor_clone(arg);
38427         return (int64_t)ret_ret;
38428 }
38429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38430         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
38431         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
38432         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
38433         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
38434         return ret_conv;
38435 }
38436
38437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38438         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
38439         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
38440         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
38441         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
38442         *ret_ret = SocketDescriptor_clone(orig_conv);
38443         return (int64_t)ret_ret;
38444 }
38445
38446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38447         if ((this_ptr & 1) != 0) return;
38448         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38449         CHECK_ACCESS(this_ptr_ptr);
38450         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
38451         FREE((void*)this_ptr);
38452         SocketDescriptor_free(this_ptr_conv);
38453 }
38454
38455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38456         LDKPeerHandleError this_obj_conv;
38457         this_obj_conv.inner = (void*)(this_obj & (~1));
38458         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38460         PeerHandleError_free(this_obj_conv);
38461 }
38462
38463 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
38464         LDKPeerHandleError this_ptr_conv;
38465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38466         this_ptr_conv.is_owned = false;
38467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38468         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
38469         return ret_conv;
38470 }
38471
38472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
38473         LDKPeerHandleError this_ptr_conv;
38474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38475         this_ptr_conv.is_owned = false;
38476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38477         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
38478 }
38479
38480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
38481         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
38482         int64_t ret_ref = 0;
38483         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38484         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38486         ret_ref = (uintptr_t)ret_var.inner;
38487         if (ret_var.is_owned) {
38488                 ret_ref |= 1;
38489         }
38490         return ret_ref;
38491 }
38492
38493 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
38494         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
38495 int64_t ret_ref = 0;
38496 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38497 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38498 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38499 ret_ref = (uintptr_t)ret_var.inner;
38500 if (ret_var.is_owned) {
38501         ret_ref |= 1;
38502 }
38503         return ret_ref;
38504 }
38505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38506         LDKPeerHandleError arg_conv;
38507         arg_conv.inner = (void*)(arg & (~1));
38508         arg_conv.is_owned = false;
38509         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38510         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
38511         return ret_conv;
38512 }
38513
38514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38515         LDKPeerHandleError orig_conv;
38516         orig_conv.inner = (void*)(orig & (~1));
38517         orig_conv.is_owned = false;
38518         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38519         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
38520         int64_t ret_ref = 0;
38521         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38522         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38524         ret_ref = (uintptr_t)ret_var.inner;
38525         if (ret_var.is_owned) {
38526                 ret_ref |= 1;
38527         }
38528         return ret_ref;
38529 }
38530
38531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38532         LDKPeerManager this_obj_conv;
38533         this_obj_conv.inner = (void*)(this_obj & (~1));
38534         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38536         PeerManager_free(this_obj_conv);
38537 }
38538
38539 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) {
38540         LDKMessageHandler message_handler_conv;
38541         message_handler_conv.inner = (void*)(message_handler & (~1));
38542         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
38543         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
38544         // WARNING: we need a move here but no clone is available for LDKMessageHandler
38545         LDKSecretKey our_node_secret_ref;
38546         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
38547         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
38548         unsigned char ephemeral_random_data_arr[32];
38549         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
38550         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
38551         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
38552         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
38553         CHECK_ACCESS(logger_ptr);
38554         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
38555         if (logger_conv.free == LDKLogger_JCalls_free) {
38556                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38557                 LDKLogger_JCalls_cloned(&logger_conv);
38558         }
38559         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
38560         CHECK_ACCESS(custom_message_handler_ptr);
38561         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
38562         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
38563                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38564                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
38565         }
38566         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
38567         int64_t ret_ref = 0;
38568         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38569         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38570         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38571         ret_ref = (uintptr_t)ret_var.inner;
38572         if (ret_var.is_owned) {
38573                 ret_ref |= 1;
38574         }
38575         return ret_ref;
38576 }
38577
38578 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
38579         LDKPeerManager this_arg_conv;
38580         this_arg_conv.inner = (void*)(this_arg & (~1));
38581         this_arg_conv.is_owned = false;
38582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38583         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
38584         jobjectArray ret_arr = NULL;
38585         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
38586         ;
38587         for (size_t i = 0; i < ret_var.datalen; i++) {
38588                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
38589                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
38590                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
38591         }
38592         
38593         FREE(ret_var.data);
38594         return ret_arr;
38595 }
38596
38597 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) {
38598         LDKPeerManager this_arg_conv;
38599         this_arg_conv.inner = (void*)(this_arg & (~1));
38600         this_arg_conv.is_owned = false;
38601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38602         LDKPublicKey their_node_id_ref;
38603         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
38604         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
38605         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
38606         CHECK_ACCESS(descriptor_ptr);
38607         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
38608         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
38609                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38610                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
38611         }
38612         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
38613         CHECK_ACCESS(remote_network_address_ptr);
38614         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
38615         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
38616         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
38617         return (int64_t)ret_conv;
38618 }
38619
38620 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) {
38621         LDKPeerManager this_arg_conv;
38622         this_arg_conv.inner = (void*)(this_arg & (~1));
38623         this_arg_conv.is_owned = false;
38624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38625         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
38626         CHECK_ACCESS(descriptor_ptr);
38627         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
38628         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
38629                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38630                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
38631         }
38632         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
38633         CHECK_ACCESS(remote_network_address_ptr);
38634         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
38635         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
38636         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
38637         return (int64_t)ret_conv;
38638 }
38639
38640 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) {
38641         LDKPeerManager this_arg_conv;
38642         this_arg_conv.inner = (void*)(this_arg & (~1));
38643         this_arg_conv.is_owned = false;
38644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38645         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
38646         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
38647         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
38648         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
38649         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
38650         return (int64_t)ret_conv;
38651 }
38652
38653 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) {
38654         LDKPeerManager this_arg_conv;
38655         this_arg_conv.inner = (void*)(this_arg & (~1));
38656         this_arg_conv.is_owned = false;
38657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38658         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
38659         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
38660         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
38661         LDKu8slice data_ref;
38662         data_ref.datalen = (*env)->GetArrayLength(env, data);
38663         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
38664         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
38665         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
38666         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
38667         return (int64_t)ret_conv;
38668 }
38669
38670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
38671         LDKPeerManager this_arg_conv;
38672         this_arg_conv.inner = (void*)(this_arg & (~1));
38673         this_arg_conv.is_owned = false;
38674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38675         PeerManager_process_events(&this_arg_conv);
38676 }
38677
38678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
38679         LDKPeerManager this_arg_conv;
38680         this_arg_conv.inner = (void*)(this_arg & (~1));
38681         this_arg_conv.is_owned = false;
38682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38683         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
38684         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
38685         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
38686         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
38687 }
38688
38689 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) {
38690         LDKPeerManager this_arg_conv;
38691         this_arg_conv.inner = (void*)(this_arg & (~1));
38692         this_arg_conv.is_owned = false;
38693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38694         LDKPublicKey node_id_ref;
38695         CHECK((*env)->GetArrayLength(env, node_id) == 33);
38696         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
38697         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
38698 }
38699
38700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
38701         LDKPeerManager this_arg_conv;
38702         this_arg_conv.inner = (void*)(this_arg & (~1));
38703         this_arg_conv.is_owned = false;
38704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38705         PeerManager_disconnect_all_peers(&this_arg_conv);
38706 }
38707
38708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
38709         LDKPeerManager this_arg_conv;
38710         this_arg_conv.inner = (void*)(this_arg & (~1));
38711         this_arg_conv.is_owned = false;
38712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38713         PeerManager_timer_tick_occurred(&this_arg_conv);
38714 }
38715
38716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
38717         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
38718         return ret_conv;
38719 }
38720
38721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
38722         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
38723         return ret_conv;
38724 }
38725
38726 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
38727         unsigned char commitment_seed_arr[32];
38728         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
38729         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
38730         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
38731         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38732         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
38733         return ret_arr;
38734 }
38735
38736 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) {
38737         LDKCVec_u8Z to_holder_script_ref;
38738         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
38739         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
38740         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
38741         LDKCVec_u8Z to_counterparty_script_ref;
38742         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
38743         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
38744         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
38745         LDKOutPoint funding_outpoint_conv;
38746         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
38747         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
38748         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
38749         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
38750         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);
38751         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38752         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38753         Transaction_free(ret_var);
38754         return ret_arr;
38755 }
38756
38757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38758         LDKCounterpartyCommitmentSecrets this_obj_conv;
38759         this_obj_conv.inner = (void*)(this_obj & (~1));
38760         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38762         CounterpartyCommitmentSecrets_free(this_obj_conv);
38763 }
38764
38765 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
38766         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
38767 int64_t ret_ref = 0;
38768 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38769 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38770 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38771 ret_ref = (uintptr_t)ret_var.inner;
38772 if (ret_var.is_owned) {
38773         ret_ref |= 1;
38774 }
38775         return ret_ref;
38776 }
38777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38778         LDKCounterpartyCommitmentSecrets arg_conv;
38779         arg_conv.inner = (void*)(arg & (~1));
38780         arg_conv.is_owned = false;
38781         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38782         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
38783         return ret_conv;
38784 }
38785
38786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38787         LDKCounterpartyCommitmentSecrets orig_conv;
38788         orig_conv.inner = (void*)(orig & (~1));
38789         orig_conv.is_owned = false;
38790         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38791         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
38792         int64_t ret_ref = 0;
38793         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38794         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38796         ret_ref = (uintptr_t)ret_var.inner;
38797         if (ret_var.is_owned) {
38798                 ret_ref |= 1;
38799         }
38800         return ret_ref;
38801 }
38802
38803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
38804         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
38805         int64_t ret_ref = 0;
38806         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38807         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38809         ret_ref = (uintptr_t)ret_var.inner;
38810         if (ret_var.is_owned) {
38811                 ret_ref |= 1;
38812         }
38813         return ret_ref;
38814 }
38815
38816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
38817         LDKCounterpartyCommitmentSecrets this_arg_conv;
38818         this_arg_conv.inner = (void*)(this_arg & (~1));
38819         this_arg_conv.is_owned = false;
38820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38821         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
38822         return ret_conv;
38823 }
38824
38825 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) {
38826         LDKCounterpartyCommitmentSecrets this_arg_conv;
38827         this_arg_conv.inner = (void*)(this_arg & (~1));
38828         this_arg_conv.is_owned = false;
38829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38830         LDKThirtyTwoBytes secret_ref;
38831         CHECK((*env)->GetArrayLength(env, secret) == 32);
38832         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
38833         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
38834         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
38835         return (int64_t)ret_conv;
38836 }
38837
38838 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
38839         LDKCounterpartyCommitmentSecrets 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38844         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
38845         return ret_arr;
38846 }
38847
38848 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
38849         LDKCounterpartyCommitmentSecrets obj_conv;
38850         obj_conv.inner = (void*)(obj & (~1));
38851         obj_conv.is_owned = false;
38852         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38853         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
38854         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38855         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38856         CVec_u8Z_free(ret_var);
38857         return ret_arr;
38858 }
38859
38860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38861         LDKu8slice ser_ref;
38862         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38863         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38864         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
38865         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
38866         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38867         return (int64_t)ret_conv;
38868 }
38869
38870 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) {
38871         LDKPublicKey per_commitment_point_ref;
38872         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38873         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38874         unsigned char base_secret_arr[32];
38875         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
38876         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
38877         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
38878         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
38879         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
38880         return (int64_t)ret_conv;
38881 }
38882
38883 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) {
38884         LDKPublicKey per_commitment_point_ref;
38885         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38886         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38887         LDKPublicKey base_point_ref;
38888         CHECK((*env)->GetArrayLength(env, base_point) == 33);
38889         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
38890         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
38891         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
38892         return (int64_t)ret_conv;
38893 }
38894
38895 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) {
38896         unsigned char per_commitment_secret_arr[32];
38897         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
38898         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
38899         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
38900         unsigned char countersignatory_revocation_base_secret_arr[32];
38901         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
38902         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
38903         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
38904         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
38905         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
38906         return (int64_t)ret_conv;
38907 }
38908
38909 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) {
38910         LDKPublicKey per_commitment_point_ref;
38911         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38912         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38913         LDKPublicKey countersignatory_revocation_base_point_ref;
38914         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
38915         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
38916         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
38917         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
38918         return (int64_t)ret_conv;
38919 }
38920
38921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38922         LDKTxCreationKeys this_obj_conv;
38923         this_obj_conv.inner = (void*)(this_obj & (~1));
38924         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38926         TxCreationKeys_free(this_obj_conv);
38927 }
38928
38929 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
38930         LDKTxCreationKeys this_ptr_conv;
38931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38932         this_ptr_conv.is_owned = false;
38933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38934         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38935         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
38936         return ret_arr;
38937 }
38938
38939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38940         LDKTxCreationKeys this_ptr_conv;
38941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38942         this_ptr_conv.is_owned = false;
38943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38944         LDKPublicKey val_ref;
38945         CHECK((*env)->GetArrayLength(env, val) == 33);
38946         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38947         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
38948 }
38949
38950 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38951         LDKTxCreationKeys this_ptr_conv;
38952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38953         this_ptr_conv.is_owned = false;
38954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38955         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38956         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
38957         return ret_arr;
38958 }
38959
38960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38961         LDKTxCreationKeys this_ptr_conv;
38962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38963         this_ptr_conv.is_owned = false;
38964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38965         LDKPublicKey val_ref;
38966         CHECK((*env)->GetArrayLength(env, val) == 33);
38967         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38968         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
38969 }
38970
38971 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38972         LDKTxCreationKeys this_ptr_conv;
38973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38974         this_ptr_conv.is_owned = false;
38975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38976         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38977         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
38978         return ret_arr;
38979 }
38980
38981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38982         LDKTxCreationKeys this_ptr_conv;
38983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38984         this_ptr_conv.is_owned = false;
38985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38986         LDKPublicKey val_ref;
38987         CHECK((*env)->GetArrayLength(env, val) == 33);
38988         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38989         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
38990 }
38991
38992 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38993         LDKTxCreationKeys this_ptr_conv;
38994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38995         this_ptr_conv.is_owned = false;
38996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38997         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38998         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
38999         return ret_arr;
39000 }
39001
39002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39003         LDKTxCreationKeys this_ptr_conv;
39004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39005         this_ptr_conv.is_owned = false;
39006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39007         LDKPublicKey val_ref;
39008         CHECK((*env)->GetArrayLength(env, val) == 33);
39009         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39010         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
39011 }
39012
39013 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
39014         LDKTxCreationKeys this_ptr_conv;
39015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39016         this_ptr_conv.is_owned = false;
39017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39018         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39019         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
39020         return ret_arr;
39021 }
39022
39023 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) {
39024         LDKTxCreationKeys this_ptr_conv;
39025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39026         this_ptr_conv.is_owned = false;
39027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39028         LDKPublicKey val_ref;
39029         CHECK((*env)->GetArrayLength(env, val) == 33);
39030         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39031         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
39032 }
39033
39034 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) {
39035         LDKPublicKey per_commitment_point_arg_ref;
39036         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
39037         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
39038         LDKPublicKey revocation_key_arg_ref;
39039         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
39040         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
39041         LDKPublicKey broadcaster_htlc_key_arg_ref;
39042         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
39043         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
39044         LDKPublicKey countersignatory_htlc_key_arg_ref;
39045         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
39046         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
39047         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
39048         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
39049         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
39050         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);
39051         int64_t ret_ref = 0;
39052         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39053         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39055         ret_ref = (uintptr_t)ret_var.inner;
39056         if (ret_var.is_owned) {
39057                 ret_ref |= 1;
39058         }
39059         return ret_ref;
39060 }
39061
39062 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
39063         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
39064 int64_t ret_ref = 0;
39065 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39066 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39067 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39068 ret_ref = (uintptr_t)ret_var.inner;
39069 if (ret_var.is_owned) {
39070         ret_ref |= 1;
39071 }
39072         return ret_ref;
39073 }
39074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39075         LDKTxCreationKeys arg_conv;
39076         arg_conv.inner = (void*)(arg & (~1));
39077         arg_conv.is_owned = false;
39078         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39079         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
39080         return ret_conv;
39081 }
39082
39083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39084         LDKTxCreationKeys orig_conv;
39085         orig_conv.inner = (void*)(orig & (~1));
39086         orig_conv.is_owned = false;
39087         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39088         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
39089         int64_t ret_ref = 0;
39090         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39091         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39093         ret_ref = (uintptr_t)ret_var.inner;
39094         if (ret_var.is_owned) {
39095                 ret_ref |= 1;
39096         }
39097         return ret_ref;
39098 }
39099
39100 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
39101         LDKTxCreationKeys obj_conv;
39102         obj_conv.inner = (void*)(obj & (~1));
39103         obj_conv.is_owned = false;
39104         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39105         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
39106         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39107         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39108         CVec_u8Z_free(ret_var);
39109         return ret_arr;
39110 }
39111
39112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39113         LDKu8slice ser_ref;
39114         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39115         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39116         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
39117         *ret_conv = TxCreationKeys_read(ser_ref);
39118         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39119         return (int64_t)ret_conv;
39120 }
39121
39122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39123         LDKChannelPublicKeys this_obj_conv;
39124         this_obj_conv.inner = (void*)(this_obj & (~1));
39125         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39127         ChannelPublicKeys_free(this_obj_conv);
39128 }
39129
39130 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
39131         LDKChannelPublicKeys this_ptr_conv;
39132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39133         this_ptr_conv.is_owned = false;
39134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39135         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39136         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
39137         return ret_arr;
39138 }
39139
39140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39141         LDKChannelPublicKeys this_ptr_conv;
39142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39143         this_ptr_conv.is_owned = false;
39144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39145         LDKPublicKey val_ref;
39146         CHECK((*env)->GetArrayLength(env, val) == 33);
39147         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39148         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
39149 }
39150
39151 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39152         LDKChannelPublicKeys this_ptr_conv;
39153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39154         this_ptr_conv.is_owned = false;
39155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39156         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39157         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
39158         return ret_arr;
39159 }
39160
39161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39162         LDKChannelPublicKeys this_ptr_conv;
39163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39164         this_ptr_conv.is_owned = false;
39165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39166         LDKPublicKey val_ref;
39167         CHECK((*env)->GetArrayLength(env, val) == 33);
39168         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39169         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
39170 }
39171
39172 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
39173         LDKChannelPublicKeys this_ptr_conv;
39174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39175         this_ptr_conv.is_owned = false;
39176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39177         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39178         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
39179         return ret_arr;
39180 }
39181
39182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39183         LDKChannelPublicKeys this_ptr_conv;
39184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39185         this_ptr_conv.is_owned = false;
39186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39187         LDKPublicKey val_ref;
39188         CHECK((*env)->GetArrayLength(env, val) == 33);
39189         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39190         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
39191 }
39192
39193 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39194         LDKChannelPublicKeys this_ptr_conv;
39195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39196         this_ptr_conv.is_owned = false;
39197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39198         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39199         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
39200         return ret_arr;
39201 }
39202
39203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39204         LDKChannelPublicKeys this_ptr_conv;
39205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39206         this_ptr_conv.is_owned = false;
39207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39208         LDKPublicKey val_ref;
39209         CHECK((*env)->GetArrayLength(env, val) == 33);
39210         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39211         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
39212 }
39213
39214 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39215         LDKChannelPublicKeys this_ptr_conv;
39216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39217         this_ptr_conv.is_owned = false;
39218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39219         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39220         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
39221         return ret_arr;
39222 }
39223
39224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39225         LDKChannelPublicKeys this_ptr_conv;
39226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39227         this_ptr_conv.is_owned = false;
39228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39229         LDKPublicKey val_ref;
39230         CHECK((*env)->GetArrayLength(env, val) == 33);
39231         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39232         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
39233 }
39234
39235 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) {
39236         LDKPublicKey funding_pubkey_arg_ref;
39237         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
39238         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
39239         LDKPublicKey revocation_basepoint_arg_ref;
39240         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
39241         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
39242         LDKPublicKey payment_point_arg_ref;
39243         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
39244         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
39245         LDKPublicKey delayed_payment_basepoint_arg_ref;
39246         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
39247         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
39248         LDKPublicKey htlc_basepoint_arg_ref;
39249         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
39250         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
39251         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);
39252         int64_t ret_ref = 0;
39253         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39254         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39256         ret_ref = (uintptr_t)ret_var.inner;
39257         if (ret_var.is_owned) {
39258                 ret_ref |= 1;
39259         }
39260         return ret_ref;
39261 }
39262
39263 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
39264         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
39265 int64_t ret_ref = 0;
39266 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39267 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39268 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39269 ret_ref = (uintptr_t)ret_var.inner;
39270 if (ret_var.is_owned) {
39271         ret_ref |= 1;
39272 }
39273         return ret_ref;
39274 }
39275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39276         LDKChannelPublicKeys arg_conv;
39277         arg_conv.inner = (void*)(arg & (~1));
39278         arg_conv.is_owned = false;
39279         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39280         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
39281         return ret_conv;
39282 }
39283
39284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39285         LDKChannelPublicKeys orig_conv;
39286         orig_conv.inner = (void*)(orig & (~1));
39287         orig_conv.is_owned = false;
39288         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39289         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
39290         int64_t ret_ref = 0;
39291         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39292         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39294         ret_ref = (uintptr_t)ret_var.inner;
39295         if (ret_var.is_owned) {
39296                 ret_ref |= 1;
39297         }
39298         return ret_ref;
39299 }
39300
39301 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
39302         LDKChannelPublicKeys obj_conv;
39303         obj_conv.inner = (void*)(obj & (~1));
39304         obj_conv.is_owned = false;
39305         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39306         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
39307         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39308         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39309         CVec_u8Z_free(ret_var);
39310         return ret_arr;
39311 }
39312
39313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39314         LDKu8slice ser_ref;
39315         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39316         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39317         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
39318         *ret_conv = ChannelPublicKeys_read(ser_ref);
39319         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39320         return (int64_t)ret_conv;
39321 }
39322
39323 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) {
39324         LDKPublicKey per_commitment_point_ref;
39325         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
39326         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
39327         LDKPublicKey broadcaster_delayed_payment_base_ref;
39328         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
39329         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
39330         LDKPublicKey broadcaster_htlc_base_ref;
39331         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
39332         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
39333         LDKPublicKey countersignatory_revocation_base_ref;
39334         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
39335         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
39336         LDKPublicKey countersignatory_htlc_base_ref;
39337         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
39338         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
39339         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
39340         *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);
39341         return (int64_t)ret_conv;
39342 }
39343
39344 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) {
39345         LDKPublicKey per_commitment_point_ref;
39346         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
39347         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
39348         LDKChannelPublicKeys broadcaster_keys_conv;
39349         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
39350         broadcaster_keys_conv.is_owned = false;
39351         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
39352         LDKChannelPublicKeys countersignatory_keys_conv;
39353         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
39354         countersignatory_keys_conv.is_owned = false;
39355         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
39356         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
39357         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
39358         return (int64_t)ret_conv;
39359 }
39360
39361 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) {
39362         LDKPublicKey revocation_key_ref;
39363         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
39364         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
39365         LDKPublicKey broadcaster_delayed_payment_key_ref;
39366         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
39367         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
39368         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
39369         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39370         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39371         CVec_u8Z_free(ret_var);
39372         return ret_arr;
39373 }
39374
39375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39376         LDKHTLCOutputInCommitment this_obj_conv;
39377         this_obj_conv.inner = (void*)(this_obj & (~1));
39378         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39380         HTLCOutputInCommitment_free(this_obj_conv);
39381 }
39382
39383 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
39384         LDKHTLCOutputInCommitment this_ptr_conv;
39385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39386         this_ptr_conv.is_owned = false;
39387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39388         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
39389         return ret_conv;
39390 }
39391
39392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39393         LDKHTLCOutputInCommitment this_ptr_conv;
39394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39395         this_ptr_conv.is_owned = false;
39396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39397         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
39398 }
39399
39400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39401         LDKHTLCOutputInCommitment this_ptr_conv;
39402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39403         this_ptr_conv.is_owned = false;
39404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39405         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
39406         return ret_conv;
39407 }
39408
39409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39410         LDKHTLCOutputInCommitment this_ptr_conv;
39411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39412         this_ptr_conv.is_owned = false;
39413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39414         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
39415 }
39416
39417 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
39418         LDKHTLCOutputInCommitment this_ptr_conv;
39419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39420         this_ptr_conv.is_owned = false;
39421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39422         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
39423         return ret_conv;
39424 }
39425
39426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39427         LDKHTLCOutputInCommitment this_ptr_conv;
39428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39429         this_ptr_conv.is_owned = false;
39430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39431         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
39432 }
39433
39434 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39435         LDKHTLCOutputInCommitment this_ptr_conv;
39436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39437         this_ptr_conv.is_owned = false;
39438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39439         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39440         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
39441         return ret_arr;
39442 }
39443
39444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39445         LDKHTLCOutputInCommitment this_ptr_conv;
39446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39447         this_ptr_conv.is_owned = false;
39448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39449         LDKThirtyTwoBytes val_ref;
39450         CHECK((*env)->GetArrayLength(env, val) == 32);
39451         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39452         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
39453 }
39454
39455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
39456         LDKHTLCOutputInCommitment this_ptr_conv;
39457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39458         this_ptr_conv.is_owned = false;
39459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39460         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
39461         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
39462         int64_t ret_ref = (uintptr_t)ret_copy;
39463         return ret_ref;
39464 }
39465
39466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39467         LDKHTLCOutputInCommitment this_ptr_conv;
39468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39469         this_ptr_conv.is_owned = false;
39470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39471         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
39472         CHECK_ACCESS(val_ptr);
39473         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
39474         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
39475         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
39476 }
39477
39478 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) {
39479         LDKThirtyTwoBytes payment_hash_arg_ref;
39480         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
39481         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
39482         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
39483         CHECK_ACCESS(transaction_output_index_arg_ptr);
39484         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
39485         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
39486         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
39487         int64_t ret_ref = 0;
39488         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39489         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39491         ret_ref = (uintptr_t)ret_var.inner;
39492         if (ret_var.is_owned) {
39493                 ret_ref |= 1;
39494         }
39495         return ret_ref;
39496 }
39497
39498 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
39499         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
39500 int64_t ret_ref = 0;
39501 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39502 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39503 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39504 ret_ref = (uintptr_t)ret_var.inner;
39505 if (ret_var.is_owned) {
39506         ret_ref |= 1;
39507 }
39508         return ret_ref;
39509 }
39510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39511         LDKHTLCOutputInCommitment arg_conv;
39512         arg_conv.inner = (void*)(arg & (~1));
39513         arg_conv.is_owned = false;
39514         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39515         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
39516         return ret_conv;
39517 }
39518
39519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39520         LDKHTLCOutputInCommitment orig_conv;
39521         orig_conv.inner = (void*)(orig & (~1));
39522         orig_conv.is_owned = false;
39523         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39524         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
39525         int64_t ret_ref = 0;
39526         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39527         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39529         ret_ref = (uintptr_t)ret_var.inner;
39530         if (ret_var.is_owned) {
39531                 ret_ref |= 1;
39532         }
39533         return ret_ref;
39534 }
39535
39536 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
39537         LDKHTLCOutputInCommitment obj_conv;
39538         obj_conv.inner = (void*)(obj & (~1));
39539         obj_conv.is_owned = false;
39540         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39541         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
39542         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39543         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39544         CVec_u8Z_free(ret_var);
39545         return ret_arr;
39546 }
39547
39548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39549         LDKu8slice ser_ref;
39550         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39551         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39552         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
39553         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
39554         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39555         return (int64_t)ret_conv;
39556 }
39557
39558 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) {
39559         LDKHTLCOutputInCommitment htlc_conv;
39560         htlc_conv.inner = (void*)(htlc & (~1));
39561         htlc_conv.is_owned = false;
39562         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
39563         LDKTxCreationKeys keys_conv;
39564         keys_conv.inner = (void*)(keys & (~1));
39565         keys_conv.is_owned = false;
39566         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
39567         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
39568         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39569         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39570         CVec_u8Z_free(ret_var);
39571         return ret_arr;
39572 }
39573
39574 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
39575         LDKPublicKey broadcaster_ref;
39576         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
39577         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
39578         LDKPublicKey countersignatory_ref;
39579         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
39580         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
39581         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
39582         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39583         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39584         CVec_u8Z_free(ret_var);
39585         return ret_arr;
39586 }
39587
39588 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) {
39589         unsigned char commitment_txid_arr[32];
39590         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
39591         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
39592         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
39593         LDKHTLCOutputInCommitment htlc_conv;
39594         htlc_conv.inner = (void*)(htlc & (~1));
39595         htlc_conv.is_owned = false;
39596         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
39597         LDKPublicKey broadcaster_delayed_payment_key_ref;
39598         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
39599         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
39600         LDKPublicKey revocation_key_ref;
39601         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
39602         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
39603         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);
39604         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39605         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39606         Transaction_free(ret_var);
39607         return ret_arr;
39608 }
39609
39610 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
39611         LDKPublicKey funding_pubkey_ref;
39612         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
39613         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
39614         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
39615         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39616         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39617         CVec_u8Z_free(ret_var);
39618         return ret_arr;
39619 }
39620
39621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39622         LDKChannelTransactionParameters this_obj_conv;
39623         this_obj_conv.inner = (void*)(this_obj & (~1));
39624         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39626         ChannelTransactionParameters_free(this_obj_conv);
39627 }
39628
39629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
39630         LDKChannelTransactionParameters this_ptr_conv;
39631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39632         this_ptr_conv.is_owned = false;
39633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39634         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
39635         int64_t ret_ref = 0;
39636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39639         ret_ref = (uintptr_t)ret_var.inner;
39640         if (ret_var.is_owned) {
39641                 ret_ref |= 1;
39642         }
39643         return ret_ref;
39644 }
39645
39646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39647         LDKChannelTransactionParameters this_ptr_conv;
39648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39649         this_ptr_conv.is_owned = false;
39650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39651         LDKChannelPublicKeys val_conv;
39652         val_conv.inner = (void*)(val & (~1));
39653         val_conv.is_owned = (val & 1) || (val == 0);
39654         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39655         val_conv = ChannelPublicKeys_clone(&val_conv);
39656         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
39657 }
39658
39659 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
39660         LDKChannelTransactionParameters this_ptr_conv;
39661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39662         this_ptr_conv.is_owned = false;
39663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39664         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
39665         return ret_conv;
39666 }
39667
39668 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) {
39669         LDKChannelTransactionParameters this_ptr_conv;
39670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39671         this_ptr_conv.is_owned = false;
39672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39673         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
39674 }
39675
39676 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
39677         LDKChannelTransactionParameters this_ptr_conv;
39678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39679         this_ptr_conv.is_owned = false;
39680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39681         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
39682         return ret_conv;
39683 }
39684
39685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39686         LDKChannelTransactionParameters this_ptr_conv;
39687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39688         this_ptr_conv.is_owned = false;
39689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39690         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
39691 }
39692
39693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
39694         LDKChannelTransactionParameters this_ptr_conv;
39695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39696         this_ptr_conv.is_owned = false;
39697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39698         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
39699         int64_t ret_ref = 0;
39700         if ((uintptr_t)ret_var.inner > 4096) {
39701                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39702                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39704                 ret_ref = (uintptr_t)ret_var.inner;
39705                 if (ret_var.is_owned) {
39706                         ret_ref |= 1;
39707                 }
39708         }
39709         return ret_ref;
39710 }
39711
39712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39713         LDKChannelTransactionParameters this_ptr_conv;
39714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39715         this_ptr_conv.is_owned = false;
39716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39717         LDKCounterpartyChannelTransactionParameters val_conv;
39718         val_conv.inner = (void*)(val & (~1));
39719         val_conv.is_owned = (val & 1) || (val == 0);
39720         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39721         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
39722         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
39723 }
39724
39725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39726         LDKChannelTransactionParameters this_ptr_conv;
39727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39728         this_ptr_conv.is_owned = false;
39729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39730         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
39731         int64_t ret_ref = 0;
39732         if ((uintptr_t)ret_var.inner > 4096) {
39733                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39734                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39736                 ret_ref = (uintptr_t)ret_var.inner;
39737                 if (ret_var.is_owned) {
39738                         ret_ref |= 1;
39739                 }
39740         }
39741         return ret_ref;
39742 }
39743
39744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39745         LDKChannelTransactionParameters this_ptr_conv;
39746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39747         this_ptr_conv.is_owned = false;
39748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39749         LDKOutPoint val_conv;
39750         val_conv.inner = (void*)(val & (~1));
39751         val_conv.is_owned = (val & 1) || (val == 0);
39752         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39753         val_conv = OutPoint_clone(&val_conv);
39754         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
39755 }
39756
39757 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
39758         LDKChannelTransactionParameters this_ptr_conv;
39759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39760         this_ptr_conv.is_owned = false;
39761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39762         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
39763         return ret_conv;
39764 }
39765
39766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
39767         LDKChannelTransactionParameters this_ptr_conv;
39768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39769         this_ptr_conv.is_owned = false;
39770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39771         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
39772         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
39773 }
39774
39775 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) {
39776         LDKChannelPublicKeys holder_pubkeys_arg_conv;
39777         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
39778         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
39779         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
39780         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
39781         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
39782         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
39783         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
39784         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
39785         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
39786         LDKOutPoint funding_outpoint_arg_conv;
39787         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
39788         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
39789         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
39790         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
39791         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
39792         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);
39793         int64_t ret_ref = 0;
39794         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39795         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39797         ret_ref = (uintptr_t)ret_var.inner;
39798         if (ret_var.is_owned) {
39799                 ret_ref |= 1;
39800         }
39801         return ret_ref;
39802 }
39803
39804 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
39805         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
39806 int64_t ret_ref = 0;
39807 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39808 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39809 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39810 ret_ref = (uintptr_t)ret_var.inner;
39811 if (ret_var.is_owned) {
39812         ret_ref |= 1;
39813 }
39814         return ret_ref;
39815 }
39816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39817         LDKChannelTransactionParameters arg_conv;
39818         arg_conv.inner = (void*)(arg & (~1));
39819         arg_conv.is_owned = false;
39820         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39821         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
39822         return ret_conv;
39823 }
39824
39825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39826         LDKChannelTransactionParameters orig_conv;
39827         orig_conv.inner = (void*)(orig & (~1));
39828         orig_conv.is_owned = false;
39829         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39830         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
39831         int64_t ret_ref = 0;
39832         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39833         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39835         ret_ref = (uintptr_t)ret_var.inner;
39836         if (ret_var.is_owned) {
39837                 ret_ref |= 1;
39838         }
39839         return ret_ref;
39840 }
39841
39842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39843         LDKCounterpartyChannelTransactionParameters this_obj_conv;
39844         this_obj_conv.inner = (void*)(this_obj & (~1));
39845         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39847         CounterpartyChannelTransactionParameters_free(this_obj_conv);
39848 }
39849
39850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
39851         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39853         this_ptr_conv.is_owned = false;
39854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39855         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
39856         int64_t ret_ref = 0;
39857         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39858         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39860         ret_ref = (uintptr_t)ret_var.inner;
39861         if (ret_var.is_owned) {
39862                 ret_ref |= 1;
39863         }
39864         return ret_ref;
39865 }
39866
39867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39868         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39870         this_ptr_conv.is_owned = false;
39871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39872         LDKChannelPublicKeys val_conv;
39873         val_conv.inner = (void*)(val & (~1));
39874         val_conv.is_owned = (val & 1) || (val == 0);
39875         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39876         val_conv = ChannelPublicKeys_clone(&val_conv);
39877         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
39878 }
39879
39880 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
39881         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39883         this_ptr_conv.is_owned = false;
39884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39885         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
39886         return ret_conv;
39887 }
39888
39889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
39890         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39892         this_ptr_conv.is_owned = false;
39893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39894         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
39895 }
39896
39897 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) {
39898         LDKChannelPublicKeys pubkeys_arg_conv;
39899         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
39900         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
39901         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
39902         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
39903         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
39904         int64_t ret_ref = 0;
39905         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39906         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39908         ret_ref = (uintptr_t)ret_var.inner;
39909         if (ret_var.is_owned) {
39910                 ret_ref |= 1;
39911         }
39912         return ret_ref;
39913 }
39914
39915 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
39916         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
39917 int64_t ret_ref = 0;
39918 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39919 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39920 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39921 ret_ref = (uintptr_t)ret_var.inner;
39922 if (ret_var.is_owned) {
39923         ret_ref |= 1;
39924 }
39925         return ret_ref;
39926 }
39927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39928         LDKCounterpartyChannelTransactionParameters arg_conv;
39929         arg_conv.inner = (void*)(arg & (~1));
39930         arg_conv.is_owned = false;
39931         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39932         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
39933         return ret_conv;
39934 }
39935
39936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39937         LDKCounterpartyChannelTransactionParameters orig_conv;
39938         orig_conv.inner = (void*)(orig & (~1));
39939         orig_conv.is_owned = false;
39940         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39941         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
39942         int64_t ret_ref = 0;
39943         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39944         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39946         ret_ref = (uintptr_t)ret_var.inner;
39947         if (ret_var.is_owned) {
39948                 ret_ref |= 1;
39949         }
39950         return ret_ref;
39951 }
39952
39953 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
39954         LDKChannelTransactionParameters this_arg_conv;
39955         this_arg_conv.inner = (void*)(this_arg & (~1));
39956         this_arg_conv.is_owned = false;
39957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39958         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
39959         return ret_conv;
39960 }
39961
39962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
39963         LDKChannelTransactionParameters this_arg_conv;
39964         this_arg_conv.inner = (void*)(this_arg & (~1));
39965         this_arg_conv.is_owned = false;
39966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39967         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
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_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
39980         LDKChannelTransactionParameters this_arg_conv;
39981         this_arg_conv.inner = (void*)(this_arg & (~1));
39982         this_arg_conv.is_owned = false;
39983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39984         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
39985         int64_t ret_ref = 0;
39986         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39987         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39988         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39989         ret_ref = (uintptr_t)ret_var.inner;
39990         if (ret_var.is_owned) {
39991                 ret_ref |= 1;
39992         }
39993         return ret_ref;
39994 }
39995
39996 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
39997         LDKCounterpartyChannelTransactionParameters obj_conv;
39998         obj_conv.inner = (void*)(obj & (~1));
39999         obj_conv.is_owned = false;
40000         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40001         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
40002         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40003         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40004         CVec_u8Z_free(ret_var);
40005         return ret_arr;
40006 }
40007
40008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40009         LDKu8slice ser_ref;
40010         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40011         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40012         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
40013         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
40014         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40015         return (int64_t)ret_conv;
40016 }
40017
40018 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
40019         LDKChannelTransactionParameters obj_conv;
40020         obj_conv.inner = (void*)(obj & (~1));
40021         obj_conv.is_owned = false;
40022         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40023         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
40024         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40025         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40026         CVec_u8Z_free(ret_var);
40027         return ret_arr;
40028 }
40029
40030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40031         LDKu8slice ser_ref;
40032         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40033         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40034         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
40035         *ret_conv = ChannelTransactionParameters_read(ser_ref);
40036         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40037         return (int64_t)ret_conv;
40038 }
40039
40040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40041         LDKDirectedChannelTransactionParameters this_obj_conv;
40042         this_obj_conv.inner = (void*)(this_obj & (~1));
40043         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40045         DirectedChannelTransactionParameters_free(this_obj_conv);
40046 }
40047
40048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
40049         LDKDirectedChannelTransactionParameters this_arg_conv;
40050         this_arg_conv.inner = (void*)(this_arg & (~1));
40051         this_arg_conv.is_owned = false;
40052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40053         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
40054         int64_t ret_ref = 0;
40055         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40056         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40058         ret_ref = (uintptr_t)ret_var.inner;
40059         if (ret_var.is_owned) {
40060                 ret_ref |= 1;
40061         }
40062         return ret_ref;
40063 }
40064
40065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
40066         LDKDirectedChannelTransactionParameters this_arg_conv;
40067         this_arg_conv.inner = (void*)(this_arg & (~1));
40068         this_arg_conv.is_owned = false;
40069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40070         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
40071         int64_t ret_ref = 0;
40072         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40073         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40075         ret_ref = (uintptr_t)ret_var.inner;
40076         if (ret_var.is_owned) {
40077                 ret_ref |= 1;
40078         }
40079         return ret_ref;
40080 }
40081
40082 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
40083         LDKDirectedChannelTransactionParameters this_arg_conv;
40084         this_arg_conv.inner = (void*)(this_arg & (~1));
40085         this_arg_conv.is_owned = false;
40086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40087         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
40088         return ret_conv;
40089 }
40090
40091 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
40092         LDKDirectedChannelTransactionParameters this_arg_conv;
40093         this_arg_conv.inner = (void*)(this_arg & (~1));
40094         this_arg_conv.is_owned = false;
40095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40096         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
40097         return ret_conv;
40098 }
40099
40100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
40101         LDKDirectedChannelTransactionParameters this_arg_conv;
40102         this_arg_conv.inner = (void*)(this_arg & (~1));
40103         this_arg_conv.is_owned = false;
40104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40105         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
40106         int64_t ret_ref = 0;
40107         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40108         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40110         ret_ref = (uintptr_t)ret_var.inner;
40111         if (ret_var.is_owned) {
40112                 ret_ref |= 1;
40113         }
40114         return ret_ref;
40115 }
40116
40117 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
40118         LDKDirectedChannelTransactionParameters this_arg_conv;
40119         this_arg_conv.inner = (void*)(this_arg & (~1));
40120         this_arg_conv.is_owned = false;
40121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40122         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
40123         return ret_conv;
40124 }
40125
40126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40127         LDKHolderCommitmentTransaction this_obj_conv;
40128         this_obj_conv.inner = (void*)(this_obj & (~1));
40129         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40131         HolderCommitmentTransaction_free(this_obj_conv);
40132 }
40133
40134 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
40135         LDKHolderCommitmentTransaction this_ptr_conv;
40136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40137         this_ptr_conv.is_owned = false;
40138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40139         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
40140         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
40141         return ret_arr;
40142 }
40143
40144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40145         LDKHolderCommitmentTransaction this_ptr_conv;
40146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40147         this_ptr_conv.is_owned = false;
40148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40149         LDKSignature val_ref;
40150         CHECK((*env)->GetArrayLength(env, val) == 64);
40151         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
40152         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
40153 }
40154
40155 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40156         LDKHolderCommitmentTransaction this_ptr_conv;
40157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40158         this_ptr_conv.is_owned = false;
40159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40160         LDKCVec_SignatureZ ret_var = HolderCommitmentTransaction_get_counterparty_htlc_sigs(&this_ptr_conv);
40161         jobjectArray ret_arr = NULL;
40162         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
40163         ;
40164         for (size_t i = 0; i < ret_var.datalen; i++) {
40165                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
40166                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
40167                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
40168         }
40169         
40170         FREE(ret_var.data);
40171         return ret_arr;
40172 }
40173
40174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
40175         LDKHolderCommitmentTransaction this_ptr_conv;
40176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40177         this_ptr_conv.is_owned = false;
40178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40179         LDKCVec_SignatureZ val_constr;
40180         val_constr.datalen = (*env)->GetArrayLength(env, val);
40181         if (val_constr.datalen > 0)
40182                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
40183         else
40184                 val_constr.data = NULL;
40185         for (size_t i = 0; i < val_constr.datalen; i++) {
40186                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
40187                 LDKSignature val_conv_8_ref;
40188                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
40189                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
40190                 val_constr.data[i] = val_conv_8_ref;
40191         }
40192         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
40193 }
40194
40195 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
40196         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
40197 int64_t ret_ref = 0;
40198 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40199 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40200 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40201 ret_ref = (uintptr_t)ret_var.inner;
40202 if (ret_var.is_owned) {
40203         ret_ref |= 1;
40204 }
40205         return ret_ref;
40206 }
40207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40208         LDKHolderCommitmentTransaction arg_conv;
40209         arg_conv.inner = (void*)(arg & (~1));
40210         arg_conv.is_owned = false;
40211         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40212         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
40213         return ret_conv;
40214 }
40215
40216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40217         LDKHolderCommitmentTransaction orig_conv;
40218         orig_conv.inner = (void*)(orig & (~1));
40219         orig_conv.is_owned = false;
40220         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40221         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
40222         int64_t ret_ref = 0;
40223         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40224         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40226         ret_ref = (uintptr_t)ret_var.inner;
40227         if (ret_var.is_owned) {
40228                 ret_ref |= 1;
40229         }
40230         return ret_ref;
40231 }
40232
40233 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
40234         LDKHolderCommitmentTransaction obj_conv;
40235         obj_conv.inner = (void*)(obj & (~1));
40236         obj_conv.is_owned = false;
40237         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40238         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
40239         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40240         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40241         CVec_u8Z_free(ret_var);
40242         return ret_arr;
40243 }
40244
40245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40246         LDKu8slice ser_ref;
40247         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40248         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40249         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
40250         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
40251         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40252         return (int64_t)ret_conv;
40253 }
40254
40255 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) {
40256         LDKCommitmentTransaction commitment_tx_conv;
40257         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
40258         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
40259         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
40260         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
40261         LDKSignature counterparty_sig_ref;
40262         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
40263         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
40264         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
40265         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
40266         if (counterparty_htlc_sigs_constr.datalen > 0)
40267                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
40268         else
40269                 counterparty_htlc_sigs_constr.data = NULL;
40270         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
40271                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
40272                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
40273                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
40274                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
40275                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
40276         }
40277         LDKPublicKey holder_funding_key_ref;
40278         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
40279         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
40280         LDKPublicKey counterparty_funding_key_ref;
40281         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
40282         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
40283         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
40284         int64_t ret_ref = 0;
40285         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40286         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40287         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40288         ret_ref = (uintptr_t)ret_var.inner;
40289         if (ret_var.is_owned) {
40290                 ret_ref |= 1;
40291         }
40292         return ret_ref;
40293 }
40294
40295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40296         LDKBuiltCommitmentTransaction this_obj_conv;
40297         this_obj_conv.inner = (void*)(this_obj & (~1));
40298         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40300         BuiltCommitmentTransaction_free(this_obj_conv);
40301 }
40302
40303 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
40304         LDKBuiltCommitmentTransaction this_ptr_conv;
40305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40306         this_ptr_conv.is_owned = false;
40307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40308         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
40309         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40310         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40311         Transaction_free(ret_var);
40312         return ret_arr;
40313 }
40314
40315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40316         LDKBuiltCommitmentTransaction this_ptr_conv;
40317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40318         this_ptr_conv.is_owned = false;
40319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40320         LDKTransaction val_ref;
40321         val_ref.datalen = (*env)->GetArrayLength(env, val);
40322         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
40323         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
40324         val_ref.data_is_owned = true;
40325         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
40326 }
40327
40328 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
40329         LDKBuiltCommitmentTransaction this_ptr_conv;
40330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40331         this_ptr_conv.is_owned = false;
40332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40333         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40334         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
40335         return ret_arr;
40336 }
40337
40338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40339         LDKBuiltCommitmentTransaction this_ptr_conv;
40340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40341         this_ptr_conv.is_owned = false;
40342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40343         LDKThirtyTwoBytes val_ref;
40344         CHECK((*env)->GetArrayLength(env, val) == 32);
40345         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
40346         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
40347 }
40348
40349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
40350         LDKTransaction transaction_arg_ref;
40351         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
40352         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
40353         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
40354         transaction_arg_ref.data_is_owned = true;
40355         LDKThirtyTwoBytes txid_arg_ref;
40356         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
40357         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
40358         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
40359         int64_t ret_ref = 0;
40360         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40361         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40363         ret_ref = (uintptr_t)ret_var.inner;
40364         if (ret_var.is_owned) {
40365                 ret_ref |= 1;
40366         }
40367         return ret_ref;
40368 }
40369
40370 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
40371         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
40372 int64_t ret_ref = 0;
40373 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40374 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40375 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40376 ret_ref = (uintptr_t)ret_var.inner;
40377 if (ret_var.is_owned) {
40378         ret_ref |= 1;
40379 }
40380         return ret_ref;
40381 }
40382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40383         LDKBuiltCommitmentTransaction arg_conv;
40384         arg_conv.inner = (void*)(arg & (~1));
40385         arg_conv.is_owned = false;
40386         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40387         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
40388         return ret_conv;
40389 }
40390
40391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40392         LDKBuiltCommitmentTransaction orig_conv;
40393         orig_conv.inner = (void*)(orig & (~1));
40394         orig_conv.is_owned = false;
40395         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40396         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
40397         int64_t ret_ref = 0;
40398         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40399         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40401         ret_ref = (uintptr_t)ret_var.inner;
40402         if (ret_var.is_owned) {
40403                 ret_ref |= 1;
40404         }
40405         return ret_ref;
40406 }
40407
40408 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
40409         LDKBuiltCommitmentTransaction obj_conv;
40410         obj_conv.inner = (void*)(obj & (~1));
40411         obj_conv.is_owned = false;
40412         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40413         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
40414         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40415         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40416         CVec_u8Z_free(ret_var);
40417         return ret_arr;
40418 }
40419
40420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40421         LDKu8slice ser_ref;
40422         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40423         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40424         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
40425         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
40426         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40427         return (int64_t)ret_conv;
40428 }
40429
40430 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) {
40431         LDKBuiltCommitmentTransaction this_arg_conv;
40432         this_arg_conv.inner = (void*)(this_arg & (~1));
40433         this_arg_conv.is_owned = false;
40434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40435         LDKu8slice funding_redeemscript_ref;
40436         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
40437         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
40438         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40439         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
40440         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
40441         return ret_arr;
40442 }
40443
40444 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) {
40445         LDKBuiltCommitmentTransaction this_arg_conv;
40446         this_arg_conv.inner = (void*)(this_arg & (~1));
40447         this_arg_conv.is_owned = false;
40448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40449         unsigned char funding_key_arr[32];
40450         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
40451         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
40452         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
40453         LDKu8slice funding_redeemscript_ref;
40454         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
40455         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
40456         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
40457         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
40458         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
40459         return ret_arr;
40460 }
40461
40462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40463         LDKClosingTransaction this_obj_conv;
40464         this_obj_conv.inner = (void*)(this_obj & (~1));
40465         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40467         ClosingTransaction_free(this_obj_conv);
40468 }
40469
40470 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
40471         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
40472 int64_t ret_ref = 0;
40473 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40474 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40475 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40476 ret_ref = (uintptr_t)ret_var.inner;
40477 if (ret_var.is_owned) {
40478         ret_ref |= 1;
40479 }
40480         return ret_ref;
40481 }
40482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40483         LDKClosingTransaction arg_conv;
40484         arg_conv.inner = (void*)(arg & (~1));
40485         arg_conv.is_owned = false;
40486         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40487         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
40488         return ret_conv;
40489 }
40490
40491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40492         LDKClosingTransaction orig_conv;
40493         orig_conv.inner = (void*)(orig & (~1));
40494         orig_conv.is_owned = false;
40495         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40496         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
40497         int64_t ret_ref = 0;
40498         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40499         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40501         ret_ref = (uintptr_t)ret_var.inner;
40502         if (ret_var.is_owned) {
40503                 ret_ref |= 1;
40504         }
40505         return ret_ref;
40506 }
40507
40508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
40509         LDKClosingTransaction o_conv;
40510         o_conv.inner = (void*)(o & (~1));
40511         o_conv.is_owned = false;
40512         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40513         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
40514         return ret_conv;
40515 }
40516
40517 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) {
40518         LDKCVec_u8Z to_holder_script_ref;
40519         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
40520         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
40521         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
40522         LDKCVec_u8Z to_counterparty_script_ref;
40523         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
40524         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
40525         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
40526         LDKOutPoint funding_outpoint_conv;
40527         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
40528         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
40529         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
40530         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
40531         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
40532         int64_t ret_ref = 0;
40533         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40534         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40536         ret_ref = (uintptr_t)ret_var.inner;
40537         if (ret_var.is_owned) {
40538                 ret_ref |= 1;
40539         }
40540         return ret_ref;
40541 }
40542
40543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
40544         LDKClosingTransaction this_arg_conv;
40545         this_arg_conv.inner = (void*)(this_arg & (~1));
40546         this_arg_conv.is_owned = false;
40547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40548         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
40549         int64_t ret_ref = 0;
40550         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40551         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40553         ret_ref = (uintptr_t)ret_var.inner;
40554         if (ret_var.is_owned) {
40555                 ret_ref |= 1;
40556         }
40557         return ret_ref;
40558 }
40559
40560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
40561         LDKClosingTransaction this_arg_conv;
40562         this_arg_conv.inner = (void*)(this_arg & (~1));
40563         this_arg_conv.is_owned = false;
40564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40565         LDKOutPoint funding_outpoint_conv;
40566         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
40567         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
40568         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
40569         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
40570         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
40571         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
40572         return (int64_t)ret_conv;
40573 }
40574
40575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
40576         LDKClosingTransaction this_arg_conv;
40577         this_arg_conv.inner = (void*)(this_arg & (~1));
40578         this_arg_conv.is_owned = false;
40579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40580         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
40581         return ret_conv;
40582 }
40583
40584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
40585         LDKClosingTransaction this_arg_conv;
40586         this_arg_conv.inner = (void*)(this_arg & (~1));
40587         this_arg_conv.is_owned = false;
40588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40589         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
40590         return ret_conv;
40591 }
40592
40593 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40594         LDKClosingTransaction this_arg_conv;
40595         this_arg_conv.inner = (void*)(this_arg & (~1));
40596         this_arg_conv.is_owned = false;
40597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40598         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
40599         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40600         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40601         return ret_arr;
40602 }
40603
40604 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40605         LDKClosingTransaction this_arg_conv;
40606         this_arg_conv.inner = (void*)(this_arg & (~1));
40607         this_arg_conv.is_owned = false;
40608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40609         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
40610         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40611         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40612         return ret_arr;
40613 }
40614
40615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40616         LDKTrustedClosingTransaction this_obj_conv;
40617         this_obj_conv.inner = (void*)(this_obj & (~1));
40618         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40620         TrustedClosingTransaction_free(this_obj_conv);
40621 }
40622
40623 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
40624         LDKTrustedClosingTransaction 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         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
40629         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40630         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40631         Transaction_free(ret_var);
40632         return ret_arr;
40633 }
40634
40635 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) {
40636         LDKTrustedClosingTransaction this_arg_conv;
40637         this_arg_conv.inner = (void*)(this_arg & (~1));
40638         this_arg_conv.is_owned = false;
40639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40640         LDKu8slice funding_redeemscript_ref;
40641         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
40642         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
40643         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40644         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
40645         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
40646         return ret_arr;
40647 }
40648
40649 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) {
40650         LDKTrustedClosingTransaction this_arg_conv;
40651         this_arg_conv.inner = (void*)(this_arg & (~1));
40652         this_arg_conv.is_owned = false;
40653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40654         unsigned char funding_key_arr[32];
40655         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
40656         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
40657         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
40658         LDKu8slice funding_redeemscript_ref;
40659         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
40660         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
40661         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
40662         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
40663         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
40664         return ret_arr;
40665 }
40666
40667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40668         LDKCommitmentTransaction this_obj_conv;
40669         this_obj_conv.inner = (void*)(this_obj & (~1));
40670         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40672         CommitmentTransaction_free(this_obj_conv);
40673 }
40674
40675 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
40676         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
40677 int64_t ret_ref = 0;
40678 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40679 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40680 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40681 ret_ref = (uintptr_t)ret_var.inner;
40682 if (ret_var.is_owned) {
40683         ret_ref |= 1;
40684 }
40685         return ret_ref;
40686 }
40687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40688         LDKCommitmentTransaction arg_conv;
40689         arg_conv.inner = (void*)(arg & (~1));
40690         arg_conv.is_owned = false;
40691         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40692         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
40693         return ret_conv;
40694 }
40695
40696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40697         LDKCommitmentTransaction orig_conv;
40698         orig_conv.inner = (void*)(orig & (~1));
40699         orig_conv.is_owned = false;
40700         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40701         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
40702         int64_t ret_ref = 0;
40703         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40704         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40706         ret_ref = (uintptr_t)ret_var.inner;
40707         if (ret_var.is_owned) {
40708                 ret_ref |= 1;
40709         }
40710         return ret_ref;
40711 }
40712
40713 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
40714         LDKCommitmentTransaction obj_conv;
40715         obj_conv.inner = (void*)(obj & (~1));
40716         obj_conv.is_owned = false;
40717         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40718         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
40719         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40720         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40721         CVec_u8Z_free(ret_var);
40722         return ret_arr;
40723 }
40724
40725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40726         LDKu8slice ser_ref;
40727         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40728         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40729         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
40730         *ret_conv = CommitmentTransaction_read(ser_ref);
40731         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40732         return (int64_t)ret_conv;
40733 }
40734
40735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
40736         LDKCommitmentTransaction this_arg_conv;
40737         this_arg_conv.inner = (void*)(this_arg & (~1));
40738         this_arg_conv.is_owned = false;
40739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40740         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
40741         return ret_conv;
40742 }
40743
40744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
40745         LDKCommitmentTransaction this_arg_conv;
40746         this_arg_conv.inner = (void*)(this_arg & (~1));
40747         this_arg_conv.is_owned = false;
40748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40749         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
40750         return ret_conv;
40751 }
40752
40753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
40754         LDKCommitmentTransaction this_arg_conv;
40755         this_arg_conv.inner = (void*)(this_arg & (~1));
40756         this_arg_conv.is_owned = false;
40757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40758         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
40759         return ret_conv;
40760 }
40761
40762 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
40763         LDKCommitmentTransaction this_arg_conv;
40764         this_arg_conv.inner = (void*)(this_arg & (~1));
40765         this_arg_conv.is_owned = false;
40766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40767         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
40768         return ret_conv;
40769 }
40770
40771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
40772         LDKCommitmentTransaction this_arg_conv;
40773         this_arg_conv.inner = (void*)(this_arg & (~1));
40774         this_arg_conv.is_owned = false;
40775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40776         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
40777         int64_t ret_ref = 0;
40778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40781         ret_ref = (uintptr_t)ret_var.inner;
40782         if (ret_var.is_owned) {
40783                 ret_ref |= 1;
40784         }
40785         return ret_ref;
40786 }
40787
40788 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) {
40789         LDKCommitmentTransaction this_arg_conv;
40790         this_arg_conv.inner = (void*)(this_arg & (~1));
40791         this_arg_conv.is_owned = false;
40792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40793         LDKDirectedChannelTransactionParameters channel_parameters_conv;
40794         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
40795         channel_parameters_conv.is_owned = false;
40796         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
40797         LDKChannelPublicKeys broadcaster_keys_conv;
40798         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
40799         broadcaster_keys_conv.is_owned = false;
40800         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
40801         LDKChannelPublicKeys countersignatory_keys_conv;
40802         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
40803         countersignatory_keys_conv.is_owned = false;
40804         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
40805         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
40806         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
40807         return (int64_t)ret_conv;
40808 }
40809
40810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40811         LDKTrustedCommitmentTransaction this_obj_conv;
40812         this_obj_conv.inner = (void*)(this_obj & (~1));
40813         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40815         TrustedCommitmentTransaction_free(this_obj_conv);
40816 }
40817
40818 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
40819         LDKTrustedCommitmentTransaction this_arg_conv;
40820         this_arg_conv.inner = (void*)(this_arg & (~1));
40821         this_arg_conv.is_owned = false;
40822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40823         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40824         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
40825         return ret_arr;
40826 }
40827
40828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
40829         LDKTrustedCommitmentTransaction this_arg_conv;
40830         this_arg_conv.inner = (void*)(this_arg & (~1));
40831         this_arg_conv.is_owned = false;
40832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40833         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
40834         int64_t ret_ref = 0;
40835         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40836         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40838         ret_ref = (uintptr_t)ret_var.inner;
40839         if (ret_var.is_owned) {
40840                 ret_ref |= 1;
40841         }
40842         return ret_ref;
40843 }
40844
40845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
40846         LDKTrustedCommitmentTransaction this_arg_conv;
40847         this_arg_conv.inner = (void*)(this_arg & (~1));
40848         this_arg_conv.is_owned = false;
40849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40850         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
40851         int64_t ret_ref = 0;
40852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40855         ret_ref = (uintptr_t)ret_var.inner;
40856         if (ret_var.is_owned) {
40857                 ret_ref |= 1;
40858         }
40859         return ret_ref;
40860 }
40861
40862 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
40863         LDKTrustedCommitmentTransaction this_arg_conv;
40864         this_arg_conv.inner = (void*)(this_arg & (~1));
40865         this_arg_conv.is_owned = false;
40866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40867         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
40868         return ret_conv;
40869 }
40870
40871 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) {
40872         LDKTrustedCommitmentTransaction this_arg_conv;
40873         this_arg_conv.inner = (void*)(this_arg & (~1));
40874         this_arg_conv.is_owned = false;
40875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40876         unsigned char htlc_base_key_arr[32];
40877         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
40878         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
40879         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
40880         LDKDirectedChannelTransactionParameters channel_parameters_conv;
40881         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
40882         channel_parameters_conv.is_owned = false;
40883         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
40884         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
40885         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
40886         return (int64_t)ret_conv;
40887 }
40888
40889 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) {
40890         LDKPublicKey broadcaster_payment_basepoint_ref;
40891         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
40892         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
40893         LDKPublicKey countersignatory_payment_basepoint_ref;
40894         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
40895         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
40896         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
40897         return ret_conv;
40898 }
40899
40900 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40901         LDKInitFeatures a_conv;
40902         a_conv.inner = (void*)(a & (~1));
40903         a_conv.is_owned = false;
40904         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40905         LDKInitFeatures b_conv;
40906         b_conv.inner = (void*)(b & (~1));
40907         b_conv.is_owned = false;
40908         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40909         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
40910         return ret_conv;
40911 }
40912
40913 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40914         LDKNodeFeatures a_conv;
40915         a_conv.inner = (void*)(a & (~1));
40916         a_conv.is_owned = false;
40917         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40918         LDKNodeFeatures b_conv;
40919         b_conv.inner = (void*)(b & (~1));
40920         b_conv.is_owned = false;
40921         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40922         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
40923         return ret_conv;
40924 }
40925
40926 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40927         LDKChannelFeatures a_conv;
40928         a_conv.inner = (void*)(a & (~1));
40929         a_conv.is_owned = false;
40930         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40931         LDKChannelFeatures b_conv;
40932         b_conv.inner = (void*)(b & (~1));
40933         b_conv.is_owned = false;
40934         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40935         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
40936         return ret_conv;
40937 }
40938
40939 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40940         LDKInvoiceFeatures a_conv;
40941         a_conv.inner = (void*)(a & (~1));
40942         a_conv.is_owned = false;
40943         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40944         LDKInvoiceFeatures b_conv;
40945         b_conv.inner = (void*)(b & (~1));
40946         b_conv.is_owned = false;
40947         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40948         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
40949         return ret_conv;
40950 }
40951
40952 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40953         LDKChannelTypeFeatures a_conv;
40954         a_conv.inner = (void*)(a & (~1));
40955         a_conv.is_owned = false;
40956         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40957         LDKChannelTypeFeatures b_conv;
40958         b_conv.inner = (void*)(b & (~1));
40959         b_conv.is_owned = false;
40960         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40961         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
40962         return ret_conv;
40963 }
40964
40965 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
40966         LDKInitFeatures ret_var = InitFeatures_clone(arg);
40967 int64_t ret_ref = 0;
40968 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40969 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40970 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40971 ret_ref = (uintptr_t)ret_var.inner;
40972 if (ret_var.is_owned) {
40973         ret_ref |= 1;
40974 }
40975         return ret_ref;
40976 }
40977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40978         LDKInitFeatures arg_conv;
40979         arg_conv.inner = (void*)(arg & (~1));
40980         arg_conv.is_owned = false;
40981         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40982         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
40983         return ret_conv;
40984 }
40985
40986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40987         LDKInitFeatures orig_conv;
40988         orig_conv.inner = (void*)(orig & (~1));
40989         orig_conv.is_owned = false;
40990         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40991         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
40992         int64_t ret_ref = 0;
40993         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40994         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40995         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40996         ret_ref = (uintptr_t)ret_var.inner;
40997         if (ret_var.is_owned) {
40998                 ret_ref |= 1;
40999         }
41000         return ret_ref;
41001 }
41002
41003 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
41004         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
41005 int64_t ret_ref = 0;
41006 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41007 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41008 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41009 ret_ref = (uintptr_t)ret_var.inner;
41010 if (ret_var.is_owned) {
41011         ret_ref |= 1;
41012 }
41013         return ret_ref;
41014 }
41015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41016         LDKNodeFeatures arg_conv;
41017         arg_conv.inner = (void*)(arg & (~1));
41018         arg_conv.is_owned = false;
41019         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41020         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
41021         return ret_conv;
41022 }
41023
41024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41025         LDKNodeFeatures orig_conv;
41026         orig_conv.inner = (void*)(orig & (~1));
41027         orig_conv.is_owned = false;
41028         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41029         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
41030         int64_t ret_ref = 0;
41031         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41032         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41034         ret_ref = (uintptr_t)ret_var.inner;
41035         if (ret_var.is_owned) {
41036                 ret_ref |= 1;
41037         }
41038         return ret_ref;
41039 }
41040
41041 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
41042         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
41043 int64_t ret_ref = 0;
41044 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41045 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41046 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41047 ret_ref = (uintptr_t)ret_var.inner;
41048 if (ret_var.is_owned) {
41049         ret_ref |= 1;
41050 }
41051         return ret_ref;
41052 }
41053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41054         LDKChannelFeatures arg_conv;
41055         arg_conv.inner = (void*)(arg & (~1));
41056         arg_conv.is_owned = false;
41057         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41058         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
41059         return ret_conv;
41060 }
41061
41062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41063         LDKChannelFeatures orig_conv;
41064         orig_conv.inner = (void*)(orig & (~1));
41065         orig_conv.is_owned = false;
41066         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41067         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
41068         int64_t ret_ref = 0;
41069         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41070         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41072         ret_ref = (uintptr_t)ret_var.inner;
41073         if (ret_var.is_owned) {
41074                 ret_ref |= 1;
41075         }
41076         return ret_ref;
41077 }
41078
41079 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
41080         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
41081 int64_t ret_ref = 0;
41082 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41083 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41084 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41085 ret_ref = (uintptr_t)ret_var.inner;
41086 if (ret_var.is_owned) {
41087         ret_ref |= 1;
41088 }
41089         return ret_ref;
41090 }
41091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41092         LDKInvoiceFeatures arg_conv;
41093         arg_conv.inner = (void*)(arg & (~1));
41094         arg_conv.is_owned = false;
41095         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41096         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
41097         return ret_conv;
41098 }
41099
41100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41101         LDKInvoiceFeatures orig_conv;
41102         orig_conv.inner = (void*)(orig & (~1));
41103         orig_conv.is_owned = false;
41104         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41105         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
41106         int64_t ret_ref = 0;
41107         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41108         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41110         ret_ref = (uintptr_t)ret_var.inner;
41111         if (ret_var.is_owned) {
41112                 ret_ref |= 1;
41113         }
41114         return ret_ref;
41115 }
41116
41117 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
41118         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
41119 int64_t ret_ref = 0;
41120 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41121 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41122 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41123 ret_ref = (uintptr_t)ret_var.inner;
41124 if (ret_var.is_owned) {
41125         ret_ref |= 1;
41126 }
41127         return ret_ref;
41128 }
41129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41130         LDKChannelTypeFeatures arg_conv;
41131         arg_conv.inner = (void*)(arg & (~1));
41132         arg_conv.is_owned = false;
41133         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41134         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
41135         return ret_conv;
41136 }
41137
41138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41139         LDKChannelTypeFeatures orig_conv;
41140         orig_conv.inner = (void*)(orig & (~1));
41141         orig_conv.is_owned = false;
41142         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41143         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
41144         int64_t ret_ref = 0;
41145         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41146         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41148         ret_ref = (uintptr_t)ret_var.inner;
41149         if (ret_var.is_owned) {
41150                 ret_ref |= 1;
41151         }
41152         return ret_ref;
41153 }
41154
41155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41156         LDKInitFeatures this_obj_conv;
41157         this_obj_conv.inner = (void*)(this_obj & (~1));
41158         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41160         InitFeatures_free(this_obj_conv);
41161 }
41162
41163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41164         LDKNodeFeatures this_obj_conv;
41165         this_obj_conv.inner = (void*)(this_obj & (~1));
41166         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41168         NodeFeatures_free(this_obj_conv);
41169 }
41170
41171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41172         LDKChannelFeatures this_obj_conv;
41173         this_obj_conv.inner = (void*)(this_obj & (~1));
41174         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41176         ChannelFeatures_free(this_obj_conv);
41177 }
41178
41179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41180         LDKInvoiceFeatures this_obj_conv;
41181         this_obj_conv.inner = (void*)(this_obj & (~1));
41182         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41184         InvoiceFeatures_free(this_obj_conv);
41185 }
41186
41187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41188         LDKChannelTypeFeatures this_obj_conv;
41189         this_obj_conv.inner = (void*)(this_obj & (~1));
41190         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41192         ChannelTypeFeatures_free(this_obj_conv);
41193 }
41194
41195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
41196         LDKInitFeatures ret_var = InitFeatures_empty();
41197         int64_t ret_ref = 0;
41198         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41199         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41201         ret_ref = (uintptr_t)ret_var.inner;
41202         if (ret_var.is_owned) {
41203                 ret_ref |= 1;
41204         }
41205         return ret_ref;
41206 }
41207
41208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
41209         LDKInitFeatures ret_var = InitFeatures_known();
41210         int64_t ret_ref = 0;
41211         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41212         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41214         ret_ref = (uintptr_t)ret_var.inner;
41215         if (ret_var.is_owned) {
41216                 ret_ref |= 1;
41217         }
41218         return ret_ref;
41219 }
41220
41221 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41222         LDKInitFeatures this_arg_conv;
41223         this_arg_conv.inner = (void*)(this_arg & (~1));
41224         this_arg_conv.is_owned = false;
41225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41226         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
41227         return ret_conv;
41228 }
41229
41230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
41231         LDKNodeFeatures ret_var = NodeFeatures_empty();
41232         int64_t ret_ref = 0;
41233         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41234         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41236         ret_ref = (uintptr_t)ret_var.inner;
41237         if (ret_var.is_owned) {
41238                 ret_ref |= 1;
41239         }
41240         return ret_ref;
41241 }
41242
41243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
41244         LDKNodeFeatures ret_var = NodeFeatures_known();
41245         int64_t ret_ref = 0;
41246         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41247         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41249         ret_ref = (uintptr_t)ret_var.inner;
41250         if (ret_var.is_owned) {
41251                 ret_ref |= 1;
41252         }
41253         return ret_ref;
41254 }
41255
41256 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41257         LDKNodeFeatures this_arg_conv;
41258         this_arg_conv.inner = (void*)(this_arg & (~1));
41259         this_arg_conv.is_owned = false;
41260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41261         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
41262         return ret_conv;
41263 }
41264
41265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
41266         LDKChannelFeatures ret_var = ChannelFeatures_empty();
41267         int64_t ret_ref = 0;
41268         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41269         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41271         ret_ref = (uintptr_t)ret_var.inner;
41272         if (ret_var.is_owned) {
41273                 ret_ref |= 1;
41274         }
41275         return ret_ref;
41276 }
41277
41278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
41279         LDKChannelFeatures ret_var = ChannelFeatures_known();
41280         int64_t ret_ref = 0;
41281         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41282         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41284         ret_ref = (uintptr_t)ret_var.inner;
41285         if (ret_var.is_owned) {
41286                 ret_ref |= 1;
41287         }
41288         return ret_ref;
41289 }
41290
41291 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41292         LDKChannelFeatures this_arg_conv;
41293         this_arg_conv.inner = (void*)(this_arg & (~1));
41294         this_arg_conv.is_owned = false;
41295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41296         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
41297         return ret_conv;
41298 }
41299
41300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
41301         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
41302         int64_t ret_ref = 0;
41303         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41304         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41306         ret_ref = (uintptr_t)ret_var.inner;
41307         if (ret_var.is_owned) {
41308                 ret_ref |= 1;
41309         }
41310         return ret_ref;
41311 }
41312
41313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
41314         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
41315         int64_t ret_ref = 0;
41316         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41317         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41319         ret_ref = (uintptr_t)ret_var.inner;
41320         if (ret_var.is_owned) {
41321                 ret_ref |= 1;
41322         }
41323         return ret_ref;
41324 }
41325
41326 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41327         LDKInvoiceFeatures this_arg_conv;
41328         this_arg_conv.inner = (void*)(this_arg & (~1));
41329         this_arg_conv.is_owned = false;
41330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41331         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
41332         return ret_conv;
41333 }
41334
41335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
41336         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
41337         int64_t ret_ref = 0;
41338         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41339         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41341         ret_ref = (uintptr_t)ret_var.inner;
41342         if (ret_var.is_owned) {
41343                 ret_ref |= 1;
41344         }
41345         return ret_ref;
41346 }
41347
41348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1known(JNIEnv *env, jclass clz) {
41349         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
41350         int64_t ret_ref = 0;
41351         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41352         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41354         ret_ref = (uintptr_t)ret_var.inner;
41355         if (ret_var.is_owned) {
41356                 ret_ref |= 1;
41357         }
41358         return ret_ref;
41359 }
41360
41361 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41362         LDKChannelTypeFeatures this_arg_conv;
41363         this_arg_conv.inner = (void*)(this_arg & (~1));
41364         this_arg_conv.is_owned = false;
41365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41366         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
41367         return ret_conv;
41368 }
41369
41370 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41371         LDKInitFeatures obj_conv;
41372         obj_conv.inner = (void*)(obj & (~1));
41373         obj_conv.is_owned = false;
41374         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41375         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
41376         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41377         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41378         CVec_u8Z_free(ret_var);
41379         return ret_arr;
41380 }
41381
41382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41383         LDKu8slice ser_ref;
41384         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41385         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41386         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
41387         *ret_conv = InitFeatures_read(ser_ref);
41388         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41389         return (int64_t)ret_conv;
41390 }
41391
41392 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41393         LDKChannelFeatures obj_conv;
41394         obj_conv.inner = (void*)(obj & (~1));
41395         obj_conv.is_owned = false;
41396         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41397         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
41398         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41399         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41400         CVec_u8Z_free(ret_var);
41401         return ret_arr;
41402 }
41403
41404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41405         LDKu8slice ser_ref;
41406         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41407         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41408         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
41409         *ret_conv = ChannelFeatures_read(ser_ref);
41410         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41411         return (int64_t)ret_conv;
41412 }
41413
41414 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41415         LDKNodeFeatures obj_conv;
41416         obj_conv.inner = (void*)(obj & (~1));
41417         obj_conv.is_owned = false;
41418         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41419         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
41420         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41421         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41422         CVec_u8Z_free(ret_var);
41423         return ret_arr;
41424 }
41425
41426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41427         LDKu8slice ser_ref;
41428         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41429         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41430         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
41431         *ret_conv = NodeFeatures_read(ser_ref);
41432         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41433         return (int64_t)ret_conv;
41434 }
41435
41436 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41437         LDKInvoiceFeatures obj_conv;
41438         obj_conv.inner = (void*)(obj & (~1));
41439         obj_conv.is_owned = false;
41440         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41441         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
41442         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41443         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41444         CVec_u8Z_free(ret_var);
41445         return ret_arr;
41446 }
41447
41448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41449         LDKu8slice ser_ref;
41450         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41451         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41452         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
41453         *ret_conv = InvoiceFeatures_read(ser_ref);
41454         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41455         return (int64_t)ret_conv;
41456 }
41457
41458 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41459         LDKChannelTypeFeatures obj_conv;
41460         obj_conv.inner = (void*)(obj & (~1));
41461         obj_conv.is_owned = false;
41462         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41463         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
41464         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41465         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41466         CVec_u8Z_free(ret_var);
41467         return ret_arr;
41468 }
41469
41470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41471         LDKu8slice ser_ref;
41472         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41473         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41474         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
41475         *ret_conv = ChannelTypeFeatures_read(ser_ref);
41476         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41477         return (int64_t)ret_conv;
41478 }
41479
41480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41481         LDKInitFeatures this_arg_conv;
41482         this_arg_conv.inner = (void*)(this_arg & (~1));
41483         this_arg_conv.is_owned = false;
41484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41485         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
41486 }
41487
41488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41489         LDKInitFeatures this_arg_conv;
41490         this_arg_conv.inner = (void*)(this_arg & (~1));
41491         this_arg_conv.is_owned = false;
41492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41493         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
41494 }
41495
41496 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41497         LDKInitFeatures this_arg_conv;
41498         this_arg_conv.inner = (void*)(this_arg & (~1));
41499         this_arg_conv.is_owned = false;
41500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41501         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
41502         return ret_conv;
41503 }
41504
41505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41506         LDKNodeFeatures this_arg_conv;
41507         this_arg_conv.inner = (void*)(this_arg & (~1));
41508         this_arg_conv.is_owned = false;
41509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41510         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
41511 }
41512
41513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41514         LDKNodeFeatures this_arg_conv;
41515         this_arg_conv.inner = (void*)(this_arg & (~1));
41516         this_arg_conv.is_owned = false;
41517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41518         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
41519 }
41520
41521 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41522         LDKNodeFeatures this_arg_conv;
41523         this_arg_conv.inner = (void*)(this_arg & (~1));
41524         this_arg_conv.is_owned = false;
41525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41526         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
41527         return ret_conv;
41528 }
41529
41530 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41531         LDKInitFeatures this_arg_conv;
41532         this_arg_conv.inner = (void*)(this_arg & (~1));
41533         this_arg_conv.is_owned = false;
41534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41535         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
41536         return ret_conv;
41537 }
41538
41539 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41540         LDKNodeFeatures this_arg_conv;
41541         this_arg_conv.inner = (void*)(this_arg & (~1));
41542         this_arg_conv.is_owned = false;
41543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41544         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
41545         return ret_conv;
41546 }
41547
41548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41549         LDKInitFeatures this_arg_conv;
41550         this_arg_conv.inner = (void*)(this_arg & (~1));
41551         this_arg_conv.is_owned = false;
41552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41553         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
41554 }
41555
41556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41557         LDKInitFeatures this_arg_conv;
41558         this_arg_conv.inner = (void*)(this_arg & (~1));
41559         this_arg_conv.is_owned = false;
41560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41561         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
41562 }
41563
41564 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1initial_1routing_1sync(JNIEnv *env, jclass clz, int64_t this_arg) {
41565         LDKInitFeatures this_arg_conv;
41566         this_arg_conv.inner = (void*)(this_arg & (~1));
41567         this_arg_conv.is_owned = false;
41568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41569         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
41570         return ret_conv;
41571 }
41572
41573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41574         LDKInitFeatures this_arg_conv;
41575         this_arg_conv.inner = (void*)(this_arg & (~1));
41576         this_arg_conv.is_owned = false;
41577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41578         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
41579 }
41580
41581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41582         LDKInitFeatures this_arg_conv;
41583         this_arg_conv.inner = (void*)(this_arg & (~1));
41584         this_arg_conv.is_owned = false;
41585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41586         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
41587 }
41588
41589 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41590         LDKInitFeatures this_arg_conv;
41591         this_arg_conv.inner = (void*)(this_arg & (~1));
41592         this_arg_conv.is_owned = false;
41593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41594         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
41595         return ret_conv;
41596 }
41597
41598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41599         LDKNodeFeatures this_arg_conv;
41600         this_arg_conv.inner = (void*)(this_arg & (~1));
41601         this_arg_conv.is_owned = false;
41602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41603         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
41604 }
41605
41606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41607         LDKNodeFeatures this_arg_conv;
41608         this_arg_conv.inner = (void*)(this_arg & (~1));
41609         this_arg_conv.is_owned = false;
41610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41611         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
41612 }
41613
41614 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41615         LDKNodeFeatures this_arg_conv;
41616         this_arg_conv.inner = (void*)(this_arg & (~1));
41617         this_arg_conv.is_owned = false;
41618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41619         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
41620         return ret_conv;
41621 }
41622
41623 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41624         LDKInitFeatures this_arg_conv;
41625         this_arg_conv.inner = (void*)(this_arg & (~1));
41626         this_arg_conv.is_owned = false;
41627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41628         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
41629         return ret_conv;
41630 }
41631
41632 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41633         LDKNodeFeatures this_arg_conv;
41634         this_arg_conv.inner = (void*)(this_arg & (~1));
41635         this_arg_conv.is_owned = false;
41636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41637         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
41638         return ret_conv;
41639 }
41640
41641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41642         LDKInitFeatures this_arg_conv;
41643         this_arg_conv.inner = (void*)(this_arg & (~1));
41644         this_arg_conv.is_owned = false;
41645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41646         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
41647 }
41648
41649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41650         LDKInitFeatures this_arg_conv;
41651         this_arg_conv.inner = (void*)(this_arg & (~1));
41652         this_arg_conv.is_owned = false;
41653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41654         InitFeatures_set_gossip_queries_required(&this_arg_conv);
41655 }
41656
41657 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
41658         LDKInitFeatures this_arg_conv;
41659         this_arg_conv.inner = (void*)(this_arg & (~1));
41660         this_arg_conv.is_owned = false;
41661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41662         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
41663         return ret_conv;
41664 }
41665
41666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41667         LDKNodeFeatures this_arg_conv;
41668         this_arg_conv.inner = (void*)(this_arg & (~1));
41669         this_arg_conv.is_owned = false;
41670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41671         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
41672 }
41673
41674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41675         LDKNodeFeatures this_arg_conv;
41676         this_arg_conv.inner = (void*)(this_arg & (~1));
41677         this_arg_conv.is_owned = false;
41678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41679         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
41680 }
41681
41682 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
41683         LDKNodeFeatures this_arg_conv;
41684         this_arg_conv.inner = (void*)(this_arg & (~1));
41685         this_arg_conv.is_owned = false;
41686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41687         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
41688         return ret_conv;
41689 }
41690
41691 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
41692         LDKInitFeatures this_arg_conv;
41693         this_arg_conv.inner = (void*)(this_arg & (~1));
41694         this_arg_conv.is_owned = false;
41695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41696         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
41697         return ret_conv;
41698 }
41699
41700 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
41701         LDKNodeFeatures this_arg_conv;
41702         this_arg_conv.inner = (void*)(this_arg & (~1));
41703         this_arg_conv.is_owned = false;
41704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41705         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
41706         return ret_conv;
41707 }
41708
41709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41710         LDKInitFeatures this_arg_conv;
41711         this_arg_conv.inner = (void*)(this_arg & (~1));
41712         this_arg_conv.is_owned = false;
41713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41714         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
41715 }
41716
41717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41718         LDKInitFeatures this_arg_conv;
41719         this_arg_conv.inner = (void*)(this_arg & (~1));
41720         this_arg_conv.is_owned = false;
41721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41722         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
41723 }
41724
41725 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41726         LDKInitFeatures this_arg_conv;
41727         this_arg_conv.inner = (void*)(this_arg & (~1));
41728         this_arg_conv.is_owned = false;
41729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41730         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
41731         return ret_conv;
41732 }
41733
41734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41735         LDKNodeFeatures this_arg_conv;
41736         this_arg_conv.inner = (void*)(this_arg & (~1));
41737         this_arg_conv.is_owned = false;
41738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41739         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
41740 }
41741
41742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41743         LDKNodeFeatures this_arg_conv;
41744         this_arg_conv.inner = (void*)(this_arg & (~1));
41745         this_arg_conv.is_owned = false;
41746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41747         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
41748 }
41749
41750 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41751         LDKNodeFeatures this_arg_conv;
41752         this_arg_conv.inner = (void*)(this_arg & (~1));
41753         this_arg_conv.is_owned = false;
41754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41755         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
41756         return ret_conv;
41757 }
41758
41759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41760         LDKInvoiceFeatures this_arg_conv;
41761         this_arg_conv.inner = (void*)(this_arg & (~1));
41762         this_arg_conv.is_owned = false;
41763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41764         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
41765 }
41766
41767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41768         LDKInvoiceFeatures this_arg_conv;
41769         this_arg_conv.inner = (void*)(this_arg & (~1));
41770         this_arg_conv.is_owned = false;
41771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41772         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
41773 }
41774
41775 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41776         LDKInvoiceFeatures this_arg_conv;
41777         this_arg_conv.inner = (void*)(this_arg & (~1));
41778         this_arg_conv.is_owned = false;
41779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41780         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
41781         return ret_conv;
41782 }
41783
41784 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41785         LDKInitFeatures this_arg_conv;
41786         this_arg_conv.inner = (void*)(this_arg & (~1));
41787         this_arg_conv.is_owned = false;
41788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41789         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
41790         return ret_conv;
41791 }
41792
41793 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41794         LDKNodeFeatures this_arg_conv;
41795         this_arg_conv.inner = (void*)(this_arg & (~1));
41796         this_arg_conv.is_owned = false;
41797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41798         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
41799         return ret_conv;
41800 }
41801
41802 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41803         LDKInvoiceFeatures this_arg_conv;
41804         this_arg_conv.inner = (void*)(this_arg & (~1));
41805         this_arg_conv.is_owned = false;
41806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41807         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
41808         return ret_conv;
41809 }
41810
41811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41812         LDKInitFeatures this_arg_conv;
41813         this_arg_conv.inner = (void*)(this_arg & (~1));
41814         this_arg_conv.is_owned = false;
41815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41816         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
41817 }
41818
41819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41820         LDKInitFeatures this_arg_conv;
41821         this_arg_conv.inner = (void*)(this_arg & (~1));
41822         this_arg_conv.is_owned = false;
41823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41824         InitFeatures_set_static_remote_key_required(&this_arg_conv);
41825 }
41826
41827 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41828         LDKInitFeatures this_arg_conv;
41829         this_arg_conv.inner = (void*)(this_arg & (~1));
41830         this_arg_conv.is_owned = false;
41831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41832         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
41833         return ret_conv;
41834 }
41835
41836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41837         LDKNodeFeatures this_arg_conv;
41838         this_arg_conv.inner = (void*)(this_arg & (~1));
41839         this_arg_conv.is_owned = false;
41840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41841         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
41842 }
41843
41844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41845         LDKNodeFeatures this_arg_conv;
41846         this_arg_conv.inner = (void*)(this_arg & (~1));
41847         this_arg_conv.is_owned = false;
41848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41849         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
41850 }
41851
41852 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41853         LDKNodeFeatures this_arg_conv;
41854         this_arg_conv.inner = (void*)(this_arg & (~1));
41855         this_arg_conv.is_owned = false;
41856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41857         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
41858         return ret_conv;
41859 }
41860
41861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41862         LDKChannelTypeFeatures this_arg_conv;
41863         this_arg_conv.inner = (void*)(this_arg & (~1));
41864         this_arg_conv.is_owned = false;
41865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41866         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
41867 }
41868
41869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41870         LDKChannelTypeFeatures this_arg_conv;
41871         this_arg_conv.inner = (void*)(this_arg & (~1));
41872         this_arg_conv.is_owned = false;
41873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41874         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
41875 }
41876
41877 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41878         LDKChannelTypeFeatures this_arg_conv;
41879         this_arg_conv.inner = (void*)(this_arg & (~1));
41880         this_arg_conv.is_owned = false;
41881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41882         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
41883         return ret_conv;
41884 }
41885
41886 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41887         LDKInitFeatures this_arg_conv;
41888         this_arg_conv.inner = (void*)(this_arg & (~1));
41889         this_arg_conv.is_owned = false;
41890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41891         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
41892         return ret_conv;
41893 }
41894
41895 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41896         LDKNodeFeatures this_arg_conv;
41897         this_arg_conv.inner = (void*)(this_arg & (~1));
41898         this_arg_conv.is_owned = false;
41899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41900         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
41901         return ret_conv;
41902 }
41903
41904 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41905         LDKChannelTypeFeatures this_arg_conv;
41906         this_arg_conv.inner = (void*)(this_arg & (~1));
41907         this_arg_conv.is_owned = false;
41908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41909         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
41910         return ret_conv;
41911 }
41912
41913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41914         LDKInitFeatures this_arg_conv;
41915         this_arg_conv.inner = (void*)(this_arg & (~1));
41916         this_arg_conv.is_owned = false;
41917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41918         InitFeatures_set_payment_secret_optional(&this_arg_conv);
41919 }
41920
41921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41922         LDKInitFeatures this_arg_conv;
41923         this_arg_conv.inner = (void*)(this_arg & (~1));
41924         this_arg_conv.is_owned = false;
41925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41926         InitFeatures_set_payment_secret_required(&this_arg_conv);
41927 }
41928
41929 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41930         LDKInitFeatures this_arg_conv;
41931         this_arg_conv.inner = (void*)(this_arg & (~1));
41932         this_arg_conv.is_owned = false;
41933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41934         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
41935         return ret_conv;
41936 }
41937
41938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41939         LDKNodeFeatures this_arg_conv;
41940         this_arg_conv.inner = (void*)(this_arg & (~1));
41941         this_arg_conv.is_owned = false;
41942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41943         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
41944 }
41945
41946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41947         LDKNodeFeatures this_arg_conv;
41948         this_arg_conv.inner = (void*)(this_arg & (~1));
41949         this_arg_conv.is_owned = false;
41950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41951         NodeFeatures_set_payment_secret_required(&this_arg_conv);
41952 }
41953
41954 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41955         LDKNodeFeatures this_arg_conv;
41956         this_arg_conv.inner = (void*)(this_arg & (~1));
41957         this_arg_conv.is_owned = false;
41958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41959         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
41960         return ret_conv;
41961 }
41962
41963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41964         LDKInvoiceFeatures this_arg_conv;
41965         this_arg_conv.inner = (void*)(this_arg & (~1));
41966         this_arg_conv.is_owned = false;
41967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41968         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
41969 }
41970
41971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41972         LDKInvoiceFeatures this_arg_conv;
41973         this_arg_conv.inner = (void*)(this_arg & (~1));
41974         this_arg_conv.is_owned = false;
41975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41976         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
41977 }
41978
41979 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41980         LDKInvoiceFeatures this_arg_conv;
41981         this_arg_conv.inner = (void*)(this_arg & (~1));
41982         this_arg_conv.is_owned = false;
41983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41984         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
41985         return ret_conv;
41986 }
41987
41988 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41989         LDKInitFeatures this_arg_conv;
41990         this_arg_conv.inner = (void*)(this_arg & (~1));
41991         this_arg_conv.is_owned = false;
41992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41993         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
41994         return ret_conv;
41995 }
41996
41997 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41998         LDKNodeFeatures this_arg_conv;
41999         this_arg_conv.inner = (void*)(this_arg & (~1));
42000         this_arg_conv.is_owned = false;
42001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42002         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
42003         return ret_conv;
42004 }
42005
42006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
42007         LDKInvoiceFeatures this_arg_conv;
42008         this_arg_conv.inner = (void*)(this_arg & (~1));
42009         this_arg_conv.is_owned = false;
42010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42011         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
42012         return ret_conv;
42013 }
42014
42015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42016         LDKInitFeatures this_arg_conv;
42017         this_arg_conv.inner = (void*)(this_arg & (~1));
42018         this_arg_conv.is_owned = false;
42019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42020         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
42021 }
42022
42023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42024         LDKInitFeatures this_arg_conv;
42025         this_arg_conv.inner = (void*)(this_arg & (~1));
42026         this_arg_conv.is_owned = false;
42027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42028         InitFeatures_set_basic_mpp_required(&this_arg_conv);
42029 }
42030
42031 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
42032         LDKInitFeatures this_arg_conv;
42033         this_arg_conv.inner = (void*)(this_arg & (~1));
42034         this_arg_conv.is_owned = false;
42035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42036         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
42037         return ret_conv;
42038 }
42039
42040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42041         LDKNodeFeatures this_arg_conv;
42042         this_arg_conv.inner = (void*)(this_arg & (~1));
42043         this_arg_conv.is_owned = false;
42044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42045         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
42046 }
42047
42048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42049         LDKNodeFeatures this_arg_conv;
42050         this_arg_conv.inner = (void*)(this_arg & (~1));
42051         this_arg_conv.is_owned = false;
42052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42053         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
42054 }
42055
42056 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
42057         LDKNodeFeatures this_arg_conv;
42058         this_arg_conv.inner = (void*)(this_arg & (~1));
42059         this_arg_conv.is_owned = false;
42060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42061         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
42062         return ret_conv;
42063 }
42064
42065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42066         LDKInvoiceFeatures this_arg_conv;
42067         this_arg_conv.inner = (void*)(this_arg & (~1));
42068         this_arg_conv.is_owned = false;
42069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42070         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
42071 }
42072
42073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42074         LDKInvoiceFeatures this_arg_conv;
42075         this_arg_conv.inner = (void*)(this_arg & (~1));
42076         this_arg_conv.is_owned = false;
42077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42078         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
42079 }
42080
42081 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
42082         LDKInvoiceFeatures this_arg_conv;
42083         this_arg_conv.inner = (void*)(this_arg & (~1));
42084         this_arg_conv.is_owned = false;
42085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42086         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
42087         return ret_conv;
42088 }
42089
42090 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
42091         LDKInitFeatures this_arg_conv;
42092         this_arg_conv.inner = (void*)(this_arg & (~1));
42093         this_arg_conv.is_owned = false;
42094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42095         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
42096         return ret_conv;
42097 }
42098
42099 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
42100         LDKNodeFeatures this_arg_conv;
42101         this_arg_conv.inner = (void*)(this_arg & (~1));
42102         this_arg_conv.is_owned = false;
42103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42104         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
42105         return ret_conv;
42106 }
42107
42108 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
42109         LDKInvoiceFeatures this_arg_conv;
42110         this_arg_conv.inner = (void*)(this_arg & (~1));
42111         this_arg_conv.is_owned = false;
42112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42113         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
42114         return ret_conv;
42115 }
42116
42117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42118         LDKInitFeatures this_arg_conv;
42119         this_arg_conv.inner = (void*)(this_arg & (~1));
42120         this_arg_conv.is_owned = false;
42121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42122         InitFeatures_set_wumbo_optional(&this_arg_conv);
42123 }
42124
42125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42126         LDKInitFeatures this_arg_conv;
42127         this_arg_conv.inner = (void*)(this_arg & (~1));
42128         this_arg_conv.is_owned = false;
42129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42130         InitFeatures_set_wumbo_required(&this_arg_conv);
42131 }
42132
42133 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42134         LDKInitFeatures this_arg_conv;
42135         this_arg_conv.inner = (void*)(this_arg & (~1));
42136         this_arg_conv.is_owned = false;
42137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42138         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
42139         return ret_conv;
42140 }
42141
42142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42143         LDKNodeFeatures this_arg_conv;
42144         this_arg_conv.inner = (void*)(this_arg & (~1));
42145         this_arg_conv.is_owned = false;
42146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42147         NodeFeatures_set_wumbo_optional(&this_arg_conv);
42148 }
42149
42150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42151         LDKNodeFeatures this_arg_conv;
42152         this_arg_conv.inner = (void*)(this_arg & (~1));
42153         this_arg_conv.is_owned = false;
42154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42155         NodeFeatures_set_wumbo_required(&this_arg_conv);
42156 }
42157
42158 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42159         LDKNodeFeatures this_arg_conv;
42160         this_arg_conv.inner = (void*)(this_arg & (~1));
42161         this_arg_conv.is_owned = false;
42162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42163         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
42164         return ret_conv;
42165 }
42166
42167 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42168         LDKInitFeatures this_arg_conv;
42169         this_arg_conv.inner = (void*)(this_arg & (~1));
42170         this_arg_conv.is_owned = false;
42171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42172         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
42173         return ret_conv;
42174 }
42175
42176 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42177         LDKNodeFeatures this_arg_conv;
42178         this_arg_conv.inner = (void*)(this_arg & (~1));
42179         this_arg_conv.is_owned = false;
42180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42181         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
42182         return ret_conv;
42183 }
42184
42185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42186         LDKInitFeatures this_arg_conv;
42187         this_arg_conv.inner = (void*)(this_arg & (~1));
42188         this_arg_conv.is_owned = false;
42189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42190         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
42191 }
42192
42193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42194         LDKInitFeatures this_arg_conv;
42195         this_arg_conv.inner = (void*)(this_arg & (~1));
42196         this_arg_conv.is_owned = false;
42197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42198         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
42199 }
42200
42201 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42202         LDKInitFeatures this_arg_conv;
42203         this_arg_conv.inner = (void*)(this_arg & (~1));
42204         this_arg_conv.is_owned = false;
42205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42206         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
42207         return ret_conv;
42208 }
42209
42210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42211         LDKNodeFeatures this_arg_conv;
42212         this_arg_conv.inner = (void*)(this_arg & (~1));
42213         this_arg_conv.is_owned = false;
42214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42215         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
42216 }
42217
42218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42219         LDKNodeFeatures this_arg_conv;
42220         this_arg_conv.inner = (void*)(this_arg & (~1));
42221         this_arg_conv.is_owned = false;
42222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42223         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
42224 }
42225
42226 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42227         LDKNodeFeatures this_arg_conv;
42228         this_arg_conv.inner = (void*)(this_arg & (~1));
42229         this_arg_conv.is_owned = false;
42230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42231         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
42232         return ret_conv;
42233 }
42234
42235 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42236         LDKInitFeatures this_arg_conv;
42237         this_arg_conv.inner = (void*)(this_arg & (~1));
42238         this_arg_conv.is_owned = false;
42239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42240         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
42241         return ret_conv;
42242 }
42243
42244 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42245         LDKNodeFeatures this_arg_conv;
42246         this_arg_conv.inner = (void*)(this_arg & (~1));
42247         this_arg_conv.is_owned = false;
42248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42249         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
42250         return ret_conv;
42251 }
42252
42253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42254         LDKInitFeatures this_arg_conv;
42255         this_arg_conv.inner = (void*)(this_arg & (~1));
42256         this_arg_conv.is_owned = false;
42257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42258         InitFeatures_set_channel_type_optional(&this_arg_conv);
42259 }
42260
42261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42262         LDKInitFeatures this_arg_conv;
42263         this_arg_conv.inner = (void*)(this_arg & (~1));
42264         this_arg_conv.is_owned = false;
42265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42266         InitFeatures_set_channel_type_required(&this_arg_conv);
42267 }
42268
42269 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42270         LDKInitFeatures this_arg_conv;
42271         this_arg_conv.inner = (void*)(this_arg & (~1));
42272         this_arg_conv.is_owned = false;
42273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42274         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
42275         return ret_conv;
42276 }
42277
42278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42279         LDKNodeFeatures this_arg_conv;
42280         this_arg_conv.inner = (void*)(this_arg & (~1));
42281         this_arg_conv.is_owned = false;
42282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42283         NodeFeatures_set_channel_type_optional(&this_arg_conv);
42284 }
42285
42286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42287         LDKNodeFeatures this_arg_conv;
42288         this_arg_conv.inner = (void*)(this_arg & (~1));
42289         this_arg_conv.is_owned = false;
42290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42291         NodeFeatures_set_channel_type_required(&this_arg_conv);
42292 }
42293
42294 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42295         LDKNodeFeatures this_arg_conv;
42296         this_arg_conv.inner = (void*)(this_arg & (~1));
42297         this_arg_conv.is_owned = false;
42298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42299         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
42300         return ret_conv;
42301 }
42302
42303 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42304         LDKInitFeatures this_arg_conv;
42305         this_arg_conv.inner = (void*)(this_arg & (~1));
42306         this_arg_conv.is_owned = false;
42307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42308         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
42309         return ret_conv;
42310 }
42311
42312 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42313         LDKNodeFeatures this_arg_conv;
42314         this_arg_conv.inner = (void*)(this_arg & (~1));
42315         this_arg_conv.is_owned = false;
42316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42317         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
42318         return ret_conv;
42319 }
42320
42321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42322         LDKInitFeatures this_arg_conv;
42323         this_arg_conv.inner = (void*)(this_arg & (~1));
42324         this_arg_conv.is_owned = false;
42325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42326         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
42327 }
42328
42329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42330         LDKInitFeatures this_arg_conv;
42331         this_arg_conv.inner = (void*)(this_arg & (~1));
42332         this_arg_conv.is_owned = false;
42333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42334         InitFeatures_set_scid_privacy_required(&this_arg_conv);
42335 }
42336
42337 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42338         LDKInitFeatures this_arg_conv;
42339         this_arg_conv.inner = (void*)(this_arg & (~1));
42340         this_arg_conv.is_owned = false;
42341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42342         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
42343         return ret_conv;
42344 }
42345
42346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42347         LDKNodeFeatures this_arg_conv;
42348         this_arg_conv.inner = (void*)(this_arg & (~1));
42349         this_arg_conv.is_owned = false;
42350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42351         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
42352 }
42353
42354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42355         LDKNodeFeatures this_arg_conv;
42356         this_arg_conv.inner = (void*)(this_arg & (~1));
42357         this_arg_conv.is_owned = false;
42358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42359         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
42360 }
42361
42362 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42363         LDKNodeFeatures this_arg_conv;
42364         this_arg_conv.inner = (void*)(this_arg & (~1));
42365         this_arg_conv.is_owned = false;
42366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42367         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
42368         return ret_conv;
42369 }
42370
42371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42372         LDKChannelTypeFeatures this_arg_conv;
42373         this_arg_conv.inner = (void*)(this_arg & (~1));
42374         this_arg_conv.is_owned = false;
42375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42376         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
42377 }
42378
42379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42380         LDKChannelTypeFeatures this_arg_conv;
42381         this_arg_conv.inner = (void*)(this_arg & (~1));
42382         this_arg_conv.is_owned = false;
42383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42384         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
42385 }
42386
42387 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42388         LDKChannelTypeFeatures this_arg_conv;
42389         this_arg_conv.inner = (void*)(this_arg & (~1));
42390         this_arg_conv.is_owned = false;
42391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42392         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
42393         return ret_conv;
42394 }
42395
42396 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42397         LDKInitFeatures this_arg_conv;
42398         this_arg_conv.inner = (void*)(this_arg & (~1));
42399         this_arg_conv.is_owned = false;
42400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42401         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
42402         return ret_conv;
42403 }
42404
42405 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42406         LDKNodeFeatures this_arg_conv;
42407         this_arg_conv.inner = (void*)(this_arg & (~1));
42408         this_arg_conv.is_owned = false;
42409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42410         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
42411         return ret_conv;
42412 }
42413
42414 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42415         LDKChannelTypeFeatures this_arg_conv;
42416         this_arg_conv.inner = (void*)(this_arg & (~1));
42417         this_arg_conv.is_owned = false;
42418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42419         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
42420         return ret_conv;
42421 }
42422
42423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42424         LDKInitFeatures this_arg_conv;
42425         this_arg_conv.inner = (void*)(this_arg & (~1));
42426         this_arg_conv.is_owned = false;
42427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42428         InitFeatures_set_zero_conf_optional(&this_arg_conv);
42429 }
42430
42431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42432         LDKInitFeatures this_arg_conv;
42433         this_arg_conv.inner = (void*)(this_arg & (~1));
42434         this_arg_conv.is_owned = false;
42435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42436         InitFeatures_set_zero_conf_required(&this_arg_conv);
42437 }
42438
42439 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42440         LDKInitFeatures this_arg_conv;
42441         this_arg_conv.inner = (void*)(this_arg & (~1));
42442         this_arg_conv.is_owned = false;
42443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42444         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
42445         return ret_conv;
42446 }
42447
42448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42449         LDKNodeFeatures this_arg_conv;
42450         this_arg_conv.inner = (void*)(this_arg & (~1));
42451         this_arg_conv.is_owned = false;
42452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42453         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
42454 }
42455
42456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42457         LDKNodeFeatures this_arg_conv;
42458         this_arg_conv.inner = (void*)(this_arg & (~1));
42459         this_arg_conv.is_owned = false;
42460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42461         NodeFeatures_set_zero_conf_required(&this_arg_conv);
42462 }
42463
42464 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42465         LDKNodeFeatures this_arg_conv;
42466         this_arg_conv.inner = (void*)(this_arg & (~1));
42467         this_arg_conv.is_owned = false;
42468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42469         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
42470         return ret_conv;
42471 }
42472
42473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42474         LDKChannelTypeFeatures this_arg_conv;
42475         this_arg_conv.inner = (void*)(this_arg & (~1));
42476         this_arg_conv.is_owned = false;
42477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42478         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
42479 }
42480
42481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42482         LDKChannelTypeFeatures this_arg_conv;
42483         this_arg_conv.inner = (void*)(this_arg & (~1));
42484         this_arg_conv.is_owned = false;
42485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42486         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
42487 }
42488
42489 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42490         LDKChannelTypeFeatures this_arg_conv;
42491         this_arg_conv.inner = (void*)(this_arg & (~1));
42492         this_arg_conv.is_owned = false;
42493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42494         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
42495         return ret_conv;
42496 }
42497
42498 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42499         LDKInitFeatures this_arg_conv;
42500         this_arg_conv.inner = (void*)(this_arg & (~1));
42501         this_arg_conv.is_owned = false;
42502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42503         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
42504         return ret_conv;
42505 }
42506
42507 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42508         LDKNodeFeatures this_arg_conv;
42509         this_arg_conv.inner = (void*)(this_arg & (~1));
42510         this_arg_conv.is_owned = false;
42511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42512         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
42513         return ret_conv;
42514 }
42515
42516 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42517         LDKChannelTypeFeatures this_arg_conv;
42518         this_arg_conv.inner = (void*)(this_arg & (~1));
42519         this_arg_conv.is_owned = false;
42520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42521         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
42522         return ret_conv;
42523 }
42524
42525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42526         LDKNodeFeatures this_arg_conv;
42527         this_arg_conv.inner = (void*)(this_arg & (~1));
42528         this_arg_conv.is_owned = false;
42529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42530         NodeFeatures_set_keysend_optional(&this_arg_conv);
42531 }
42532
42533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42534         LDKNodeFeatures this_arg_conv;
42535         this_arg_conv.inner = (void*)(this_arg & (~1));
42536         this_arg_conv.is_owned = false;
42537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42538         NodeFeatures_set_keysend_required(&this_arg_conv);
42539 }
42540
42541 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
42542         LDKNodeFeatures this_arg_conv;
42543         this_arg_conv.inner = (void*)(this_arg & (~1));
42544         this_arg_conv.is_owned = false;
42545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42546         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
42547         return ret_conv;
42548 }
42549
42550 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
42551         LDKNodeFeatures this_arg_conv;
42552         this_arg_conv.inner = (void*)(this_arg & (~1));
42553         this_arg_conv.is_owned = false;
42554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42555         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
42556         return ret_conv;
42557 }
42558
42559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42560         LDKShutdownScript this_obj_conv;
42561         this_obj_conv.inner = (void*)(this_obj & (~1));
42562         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42564         ShutdownScript_free(this_obj_conv);
42565 }
42566
42567 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
42568         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
42569 int64_t ret_ref = 0;
42570 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42571 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42572 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42573 ret_ref = (uintptr_t)ret_var.inner;
42574 if (ret_var.is_owned) {
42575         ret_ref |= 1;
42576 }
42577         return ret_ref;
42578 }
42579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42580         LDKShutdownScript arg_conv;
42581         arg_conv.inner = (void*)(arg & (~1));
42582         arg_conv.is_owned = false;
42583         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42584         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
42585         return ret_conv;
42586 }
42587
42588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42589         LDKShutdownScript orig_conv;
42590         orig_conv.inner = (void*)(orig & (~1));
42591         orig_conv.is_owned = false;
42592         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42593         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
42594         int64_t ret_ref = 0;
42595         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42596         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42598         ret_ref = (uintptr_t)ret_var.inner;
42599         if (ret_var.is_owned) {
42600                 ret_ref |= 1;
42601         }
42602         return ret_ref;
42603 }
42604
42605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42606         LDKInvalidShutdownScript this_obj_conv;
42607         this_obj_conv.inner = (void*)(this_obj & (~1));
42608         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42610         InvalidShutdownScript_free(this_obj_conv);
42611 }
42612
42613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
42614         LDKInvalidShutdownScript this_ptr_conv;
42615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42616         this_ptr_conv.is_owned = false;
42617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42618         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
42619         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42620         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42621         return ret_arr;
42622 }
42623
42624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42625         LDKInvalidShutdownScript this_ptr_conv;
42626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42627         this_ptr_conv.is_owned = false;
42628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42629         LDKCVec_u8Z val_ref;
42630         val_ref.datalen = (*env)->GetArrayLength(env, val);
42631         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
42632         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
42633         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
42634 }
42635
42636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
42637         LDKCVec_u8Z script_arg_ref;
42638         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
42639         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
42640         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
42641         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
42642         int64_t ret_ref = 0;
42643         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42644         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42646         ret_ref = (uintptr_t)ret_var.inner;
42647         if (ret_var.is_owned) {
42648                 ret_ref |= 1;
42649         }
42650         return ret_ref;
42651 }
42652
42653 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
42654         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
42655 int64_t ret_ref = 0;
42656 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42657 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42658 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42659 ret_ref = (uintptr_t)ret_var.inner;
42660 if (ret_var.is_owned) {
42661         ret_ref |= 1;
42662 }
42663         return ret_ref;
42664 }
42665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42666         LDKInvalidShutdownScript arg_conv;
42667         arg_conv.inner = (void*)(arg & (~1));
42668         arg_conv.is_owned = false;
42669         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42670         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
42671         return ret_conv;
42672 }
42673
42674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42675         LDKInvalidShutdownScript orig_conv;
42676         orig_conv.inner = (void*)(orig & (~1));
42677         orig_conv.is_owned = false;
42678         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42679         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
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
42691 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
42692         LDKShutdownScript obj_conv;
42693         obj_conv.inner = (void*)(obj & (~1));
42694         obj_conv.is_owned = false;
42695         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42696         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
42697         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42698         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42699         CVec_u8Z_free(ret_var);
42700         return ret_arr;
42701 }
42702
42703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42704         LDKu8slice ser_ref;
42705         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42706         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42707         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
42708         *ret_conv = ShutdownScript_read(ser_ref);
42709         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42710         return (int64_t)ret_conv;
42711 }
42712
42713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
42714         unsigned char pubkey_hash_arr[20];
42715         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
42716         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
42717         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
42718         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
42719         int64_t ret_ref = 0;
42720         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42721         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42722         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42723         ret_ref = (uintptr_t)ret_var.inner;
42724         if (ret_var.is_owned) {
42725                 ret_ref |= 1;
42726         }
42727         return ret_ref;
42728 }
42729
42730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
42731         unsigned char script_hash_arr[32];
42732         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
42733         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
42734         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
42735         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
42736         int64_t ret_ref = 0;
42737         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42738         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42740         ret_ref = (uintptr_t)ret_var.inner;
42741         if (ret_var.is_owned) {
42742                 ret_ref |= 1;
42743         }
42744         return ret_ref;
42745 }
42746
42747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
42748         
42749         LDKu8slice program_ref;
42750         program_ref.datalen = (*env)->GetArrayLength(env, program);
42751         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
42752         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
42753         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
42754         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
42755         return (int64_t)ret_conv;
42756 }
42757
42758 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
42759         LDKShutdownScript this_arg_conv;
42760         this_arg_conv.inner = (void*)(this_arg & (~1));
42761         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
42762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42763         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
42764         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
42765         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42766         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42767         CVec_u8Z_free(ret_var);
42768         return ret_arr;
42769 }
42770
42771 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
42772         LDKShutdownScript this_arg_conv;
42773         this_arg_conv.inner = (void*)(this_arg & (~1));
42774         this_arg_conv.is_owned = false;
42775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42776         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42777         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
42778         return ret_arr;
42779 }
42780
42781 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
42782         LDKShutdownScript this_arg_conv;
42783         this_arg_conv.inner = (void*)(this_arg & (~1));
42784         this_arg_conv.is_owned = false;
42785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42786         LDKInitFeatures features_conv;
42787         features_conv.inner = (void*)(features & (~1));
42788         features_conv.is_owned = false;
42789         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
42790         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
42791         return ret_conv;
42792 }
42793
42794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42795         if ((this_ptr & 1) != 0) return;
42796         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42797         CHECK_ACCESS(this_ptr_ptr);
42798         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
42799         FREE((void*)this_ptr);
42800         CustomMessageReader_free(this_ptr_conv);
42801 }
42802
42803 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
42804         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
42805         *ret_ret = Type_clone(arg);
42806         return (int64_t)ret_ret;
42807 }
42808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42809         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
42810         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
42811         LDKType* arg_conv = (LDKType*)arg_ptr;
42812         int64_t ret_conv = Type_clone_ptr(arg_conv);
42813         return ret_conv;
42814 }
42815
42816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42817         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
42818         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
42819         LDKType* orig_conv = (LDKType*)orig_ptr;
42820         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
42821         *ret_ret = Type_clone(orig_conv);
42822         return (int64_t)ret_ret;
42823 }
42824
42825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42826         if ((this_ptr & 1) != 0) return;
42827         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42828         CHECK_ACCESS(this_ptr_ptr);
42829         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
42830         FREE((void*)this_ptr);
42831         Type_free(this_ptr_conv);
42832 }
42833
42834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42835         LDKNodeId this_obj_conv;
42836         this_obj_conv.inner = (void*)(this_obj & (~1));
42837         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42839         NodeId_free(this_obj_conv);
42840 }
42841
42842 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
42843         LDKNodeId ret_var = NodeId_clone(arg);
42844 int64_t ret_ref = 0;
42845 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42846 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42847 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42848 ret_ref = (uintptr_t)ret_var.inner;
42849 if (ret_var.is_owned) {
42850         ret_ref |= 1;
42851 }
42852         return ret_ref;
42853 }
42854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42855         LDKNodeId arg_conv;
42856         arg_conv.inner = (void*)(arg & (~1));
42857         arg_conv.is_owned = false;
42858         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42859         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
42860         return ret_conv;
42861 }
42862
42863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42864         LDKNodeId orig_conv;
42865         orig_conv.inner = (void*)(orig & (~1));
42866         orig_conv.is_owned = false;
42867         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42868         LDKNodeId ret_var = NodeId_clone(&orig_conv);
42869         int64_t ret_ref = 0;
42870         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42871         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42873         ret_ref = (uintptr_t)ret_var.inner;
42874         if (ret_var.is_owned) {
42875                 ret_ref |= 1;
42876         }
42877         return ret_ref;
42878 }
42879
42880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
42881         LDKPublicKey pubkey_ref;
42882         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
42883         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
42884         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
42885         int64_t ret_ref = 0;
42886         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42887         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42889         ret_ref = (uintptr_t)ret_var.inner;
42890         if (ret_var.is_owned) {
42891                 ret_ref |= 1;
42892         }
42893         return ret_ref;
42894 }
42895
42896 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
42897         LDKNodeId this_arg_conv;
42898         this_arg_conv.inner = (void*)(this_arg & (~1));
42899         this_arg_conv.is_owned = false;
42900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42901         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
42902         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42903         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42904         return ret_arr;
42905 }
42906
42907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
42908         LDKNodeId o_conv;
42909         o_conv.inner = (void*)(o & (~1));
42910         o_conv.is_owned = false;
42911         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42912         int64_t ret_conv = NodeId_hash(&o_conv);
42913         return ret_conv;
42914 }
42915
42916 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
42917         LDKNodeId obj_conv;
42918         obj_conv.inner = (void*)(obj & (~1));
42919         obj_conv.is_owned = false;
42920         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42921         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
42922         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42923         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42924         CVec_u8Z_free(ret_var);
42925         return ret_arr;
42926 }
42927
42928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42929         LDKu8slice ser_ref;
42930         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42931         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42932         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
42933         *ret_conv = NodeId_read(ser_ref);
42934         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42935         return (int64_t)ret_conv;
42936 }
42937
42938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42939         LDKNetworkGraph this_obj_conv;
42940         this_obj_conv.inner = (void*)(this_obj & (~1));
42941         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42943         NetworkGraph_free(this_obj_conv);
42944 }
42945
42946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42947         LDKReadOnlyNetworkGraph this_obj_conv;
42948         this_obj_conv.inner = (void*)(this_obj & (~1));
42949         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42951         ReadOnlyNetworkGraph_free(this_obj_conv);
42952 }
42953
42954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42955         if ((this_ptr & 1) != 0) return;
42956         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42957         CHECK_ACCESS(this_ptr_ptr);
42958         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
42959         FREE((void*)this_ptr);
42960         NetworkUpdate_free(this_ptr_conv);
42961 }
42962
42963 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
42964         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42965         *ret_copy = NetworkUpdate_clone(arg);
42966 int64_t ret_ref = (uintptr_t)ret_copy;
42967         return ret_ref;
42968 }
42969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42970         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
42971         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
42972         return ret_conv;
42973 }
42974
42975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42976         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
42977         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42978         *ret_copy = NetworkUpdate_clone(orig_conv);
42979         int64_t ret_ref = (uintptr_t)ret_copy;
42980         return ret_ref;
42981 }
42982
42983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
42984         LDKChannelUpdate msg_conv;
42985         msg_conv.inner = (void*)(msg & (~1));
42986         msg_conv.is_owned = (msg & 1) || (msg == 0);
42987         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
42988         msg_conv = ChannelUpdate_clone(&msg_conv);
42989         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42990         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
42991         int64_t ret_ref = (uintptr_t)ret_copy;
42992         return ret_ref;
42993 }
42994
42995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1failure(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
42996         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42997         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
42998         int64_t ret_ref = (uintptr_t)ret_copy;
42999         return ret_ref;
43000 }
43001
43002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
43003         LDKPublicKey node_id_ref;
43004         CHECK((*env)->GetArrayLength(env, node_id) == 33);
43005         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
43006         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
43007         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
43008         int64_t ret_ref = (uintptr_t)ret_copy;
43009         return ret_ref;
43010 }
43011
43012 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
43013         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
43014         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
43015         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43016         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43017         CVec_u8Z_free(ret_var);
43018         return ret_arr;
43019 }
43020
43021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43022         LDKu8slice ser_ref;
43023         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43024         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43025         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
43026         *ret_conv = NetworkUpdate_read(ser_ref);
43027         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43028         return (int64_t)ret_conv;
43029 }
43030
43031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43032         LDKP2PGossipSync this_obj_conv;
43033         this_obj_conv.inner = (void*)(this_obj & (~1));
43034         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43036         P2PGossipSync_free(this_obj_conv);
43037 }
43038
43039 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) {
43040         LDKNetworkGraph network_graph_conv;
43041         network_graph_conv.inner = (void*)(network_graph & (~1));
43042         network_graph_conv.is_owned = false;
43043         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
43044         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
43045         CHECK_ACCESS(chain_access_ptr);
43046         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
43047         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
43048         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
43049                 // Manually implement clone for Java trait instances
43050                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
43051                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43052                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
43053                 }
43054         }
43055         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
43056         CHECK_ACCESS(logger_ptr);
43057         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
43058         if (logger_conv.free == LDKLogger_JCalls_free) {
43059                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43060                 LDKLogger_JCalls_cloned(&logger_conv);
43061         }
43062         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
43063         int64_t ret_ref = 0;
43064         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43065         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43067         ret_ref = (uintptr_t)ret_var.inner;
43068         if (ret_var.is_owned) {
43069                 ret_ref |= 1;
43070         }
43071         return ret_ref;
43072 }
43073
43074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
43075         LDKP2PGossipSync this_arg_conv;
43076         this_arg_conv.inner = (void*)(this_arg & (~1));
43077         this_arg_conv.is_owned = false;
43078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43079         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
43080         CHECK_ACCESS(chain_access_ptr);
43081         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
43082         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
43083         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
43084                 // Manually implement clone for Java trait instances
43085                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
43086                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43087                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
43088                 }
43089         }
43090         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
43091 }
43092
43093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
43094         LDKNetworkGraph this_arg_conv;
43095         this_arg_conv.inner = (void*)(this_arg & (~1));
43096         this_arg_conv.is_owned = false;
43097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43098         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
43099         *ret_ret = NetworkGraph_as_EventHandler(&this_arg_conv);
43100         return (int64_t)ret_ret;
43101 }
43102
43103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
43104         LDKP2PGossipSync this_arg_conv;
43105         this_arg_conv.inner = (void*)(this_arg & (~1));
43106         this_arg_conv.is_owned = false;
43107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43108         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
43109         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
43110         return (int64_t)ret_ret;
43111 }
43112
43113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
43114         LDKP2PGossipSync this_arg_conv;
43115         this_arg_conv.inner = (void*)(this_arg & (~1));
43116         this_arg_conv.is_owned = false;
43117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43118         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
43119         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
43120         return (int64_t)ret_ret;
43121 }
43122
43123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43124         LDKChannelUpdateInfo this_obj_conv;
43125         this_obj_conv.inner = (void*)(this_obj & (~1));
43126         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43128         ChannelUpdateInfo_free(this_obj_conv);
43129 }
43130
43131 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
43132         LDKChannelUpdateInfo this_ptr_conv;
43133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43134         this_ptr_conv.is_owned = false;
43135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43136         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
43137         return ret_conv;
43138 }
43139
43140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43141         LDKChannelUpdateInfo this_ptr_conv;
43142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43143         this_ptr_conv.is_owned = false;
43144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43145         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
43146 }
43147
43148 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
43149         LDKChannelUpdateInfo this_ptr_conv;
43150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43151         this_ptr_conv.is_owned = false;
43152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43153         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
43154         return ret_conv;
43155 }
43156
43157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
43158         LDKChannelUpdateInfo this_ptr_conv;
43159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43160         this_ptr_conv.is_owned = false;
43161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43162         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
43163 }
43164
43165 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
43166         LDKChannelUpdateInfo this_ptr_conv;
43167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43168         this_ptr_conv.is_owned = false;
43169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43170         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
43171         return ret_conv;
43172 }
43173
43174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
43175         LDKChannelUpdateInfo this_ptr_conv;
43176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43177         this_ptr_conv.is_owned = false;
43178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43179         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
43180 }
43181
43182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43183         LDKChannelUpdateInfo this_ptr_conv;
43184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43185         this_ptr_conv.is_owned = false;
43186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43187         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
43188         return ret_conv;
43189 }
43190
43191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43192         LDKChannelUpdateInfo this_ptr_conv;
43193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43194         this_ptr_conv.is_owned = false;
43195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43196         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
43197 }
43198
43199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43200         LDKChannelUpdateInfo this_ptr_conv;
43201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43202         this_ptr_conv.is_owned = false;
43203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43204         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
43205         return ret_conv;
43206 }
43207
43208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43209         LDKChannelUpdateInfo this_ptr_conv;
43210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43211         this_ptr_conv.is_owned = false;
43212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43213         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
43214 }
43215
43216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
43217         LDKChannelUpdateInfo this_ptr_conv;
43218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43219         this_ptr_conv.is_owned = false;
43220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43221         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
43222         int64_t ret_ref = 0;
43223         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43224         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43226         ret_ref = (uintptr_t)ret_var.inner;
43227         if (ret_var.is_owned) {
43228                 ret_ref |= 1;
43229         }
43230         return ret_ref;
43231 }
43232
43233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43234         LDKChannelUpdateInfo this_ptr_conv;
43235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43236         this_ptr_conv.is_owned = false;
43237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43238         LDKRoutingFees val_conv;
43239         val_conv.inner = (void*)(val & (~1));
43240         val_conv.is_owned = (val & 1) || (val == 0);
43241         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43242         val_conv = RoutingFees_clone(&val_conv);
43243         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
43244 }
43245
43246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
43247         LDKChannelUpdateInfo this_ptr_conv;
43248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43249         this_ptr_conv.is_owned = false;
43250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43251         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
43252         int64_t ret_ref = 0;
43253         if ((uintptr_t)ret_var.inner > 4096) {
43254                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43255                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43257                 ret_ref = (uintptr_t)ret_var.inner;
43258                 if (ret_var.is_owned) {
43259                         ret_ref |= 1;
43260                 }
43261         }
43262         return ret_ref;
43263 }
43264
43265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43266         LDKChannelUpdateInfo this_ptr_conv;
43267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43268         this_ptr_conv.is_owned = false;
43269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43270         LDKChannelUpdate val_conv;
43271         val_conv.inner = (void*)(val & (~1));
43272         val_conv.is_owned = (val & 1) || (val == 0);
43273         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43274         val_conv = ChannelUpdate_clone(&val_conv);
43275         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
43276 }
43277
43278 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) {
43279         LDKRoutingFees fees_arg_conv;
43280         fees_arg_conv.inner = (void*)(fees_arg & (~1));
43281         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
43282         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
43283         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
43284         LDKChannelUpdate last_update_message_arg_conv;
43285         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
43286         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
43287         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
43288         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
43289         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fees_arg_conv, last_update_message_arg_conv);
43290         int64_t ret_ref = 0;
43291         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43292         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43294         ret_ref = (uintptr_t)ret_var.inner;
43295         if (ret_var.is_owned) {
43296                 ret_ref |= 1;
43297         }
43298         return ret_ref;
43299 }
43300
43301 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
43302         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
43303 int64_t ret_ref = 0;
43304 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43305 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43306 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43307 ret_ref = (uintptr_t)ret_var.inner;
43308 if (ret_var.is_owned) {
43309         ret_ref |= 1;
43310 }
43311         return ret_ref;
43312 }
43313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43314         LDKChannelUpdateInfo arg_conv;
43315         arg_conv.inner = (void*)(arg & (~1));
43316         arg_conv.is_owned = false;
43317         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43318         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
43319         return ret_conv;
43320 }
43321
43322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43323         LDKChannelUpdateInfo orig_conv;
43324         orig_conv.inner = (void*)(orig & (~1));
43325         orig_conv.is_owned = false;
43326         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43327         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
43328         int64_t ret_ref = 0;
43329         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43330         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43332         ret_ref = (uintptr_t)ret_var.inner;
43333         if (ret_var.is_owned) {
43334                 ret_ref |= 1;
43335         }
43336         return ret_ref;
43337 }
43338
43339 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
43340         LDKChannelUpdateInfo obj_conv;
43341         obj_conv.inner = (void*)(obj & (~1));
43342         obj_conv.is_owned = false;
43343         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43344         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
43345         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43346         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43347         CVec_u8Z_free(ret_var);
43348         return ret_arr;
43349 }
43350
43351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43352         LDKu8slice ser_ref;
43353         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43354         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43355         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
43356         *ret_conv = ChannelUpdateInfo_read(ser_ref);
43357         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43358         return (int64_t)ret_conv;
43359 }
43360
43361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43362         LDKChannelInfo this_obj_conv;
43363         this_obj_conv.inner = (void*)(this_obj & (~1));
43364         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43366         ChannelInfo_free(this_obj_conv);
43367 }
43368
43369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
43370         LDKChannelInfo this_ptr_conv;
43371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43372         this_ptr_conv.is_owned = false;
43373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43374         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
43375         int64_t ret_ref = 0;
43376         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43377         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43379         ret_ref = (uintptr_t)ret_var.inner;
43380         if (ret_var.is_owned) {
43381                 ret_ref |= 1;
43382         }
43383         return ret_ref;
43384 }
43385
43386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43387         LDKChannelInfo this_ptr_conv;
43388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43389         this_ptr_conv.is_owned = false;
43390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43391         LDKChannelFeatures val_conv;
43392         val_conv.inner = (void*)(val & (~1));
43393         val_conv.is_owned = (val & 1) || (val == 0);
43394         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43395         val_conv = ChannelFeatures_clone(&val_conv);
43396         ChannelInfo_set_features(&this_ptr_conv, val_conv);
43397 }
43398
43399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
43400         LDKChannelInfo this_ptr_conv;
43401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43402         this_ptr_conv.is_owned = false;
43403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43404         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
43405         int64_t ret_ref = 0;
43406         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43407         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43409         ret_ref = (uintptr_t)ret_var.inner;
43410         if (ret_var.is_owned) {
43411                 ret_ref |= 1;
43412         }
43413         return ret_ref;
43414 }
43415
43416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43417         LDKChannelInfo this_ptr_conv;
43418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43419         this_ptr_conv.is_owned = false;
43420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43421         LDKNodeId val_conv;
43422         val_conv.inner = (void*)(val & (~1));
43423         val_conv.is_owned = (val & 1) || (val == 0);
43424         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43425         val_conv = NodeId_clone(&val_conv);
43426         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
43427 }
43428
43429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
43430         LDKChannelInfo this_ptr_conv;
43431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43432         this_ptr_conv.is_owned = false;
43433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43434         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
43435         int64_t ret_ref = 0;
43436         if ((uintptr_t)ret_var.inner > 4096) {
43437                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43438                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43440                 ret_ref = (uintptr_t)ret_var.inner;
43441                 if (ret_var.is_owned) {
43442                         ret_ref |= 1;
43443                 }
43444         }
43445         return ret_ref;
43446 }
43447
43448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43449         LDKChannelInfo this_ptr_conv;
43450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43451         this_ptr_conv.is_owned = false;
43452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43453         LDKChannelUpdateInfo val_conv;
43454         val_conv.inner = (void*)(val & (~1));
43455         val_conv.is_owned = (val & 1) || (val == 0);
43456         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43457         val_conv = ChannelUpdateInfo_clone(&val_conv);
43458         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
43459 }
43460
43461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
43462         LDKChannelInfo this_ptr_conv;
43463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43464         this_ptr_conv.is_owned = false;
43465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43466         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
43467         int64_t ret_ref = 0;
43468         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43469         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43471         ret_ref = (uintptr_t)ret_var.inner;
43472         if (ret_var.is_owned) {
43473                 ret_ref |= 1;
43474         }
43475         return ret_ref;
43476 }
43477
43478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43479         LDKChannelInfo this_ptr_conv;
43480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43481         this_ptr_conv.is_owned = false;
43482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43483         LDKNodeId val_conv;
43484         val_conv.inner = (void*)(val & (~1));
43485         val_conv.is_owned = (val & 1) || (val == 0);
43486         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43487         val_conv = NodeId_clone(&val_conv);
43488         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
43489 }
43490
43491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
43492         LDKChannelInfo this_ptr_conv;
43493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43494         this_ptr_conv.is_owned = false;
43495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43496         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
43497         int64_t ret_ref = 0;
43498         if ((uintptr_t)ret_var.inner > 4096) {
43499                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43500                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43502                 ret_ref = (uintptr_t)ret_var.inner;
43503                 if (ret_var.is_owned) {
43504                         ret_ref |= 1;
43505                 }
43506         }
43507         return ret_ref;
43508 }
43509
43510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43511         LDKChannelInfo this_ptr_conv;
43512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43513         this_ptr_conv.is_owned = false;
43514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43515         LDKChannelUpdateInfo val_conv;
43516         val_conv.inner = (void*)(val & (~1));
43517         val_conv.is_owned = (val & 1) || (val == 0);
43518         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43519         val_conv = ChannelUpdateInfo_clone(&val_conv);
43520         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
43521 }
43522
43523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
43524         LDKChannelInfo 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         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
43529         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
43530         int64_t ret_ref = (uintptr_t)ret_copy;
43531         return ret_ref;
43532 }
43533
43534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43535         LDKChannelInfo this_ptr_conv;
43536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43537         this_ptr_conv.is_owned = false;
43538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43539         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
43540         CHECK_ACCESS(val_ptr);
43541         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
43542         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
43543         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
43544 }
43545
43546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
43547         LDKChannelInfo this_ptr_conv;
43548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43549         this_ptr_conv.is_owned = false;
43550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43551         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
43552         int64_t ret_ref = 0;
43553         if ((uintptr_t)ret_var.inner > 4096) {
43554                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43555                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43557                 ret_ref = (uintptr_t)ret_var.inner;
43558                 if (ret_var.is_owned) {
43559                         ret_ref |= 1;
43560                 }
43561         }
43562         return ret_ref;
43563 }
43564
43565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43566         LDKChannelInfo this_ptr_conv;
43567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43568         this_ptr_conv.is_owned = false;
43569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43570         LDKChannelAnnouncement val_conv;
43571         val_conv.inner = (void*)(val & (~1));
43572         val_conv.is_owned = (val & 1) || (val == 0);
43573         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43574         val_conv = ChannelAnnouncement_clone(&val_conv);
43575         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
43576 }
43577
43578 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
43579         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
43580 int64_t ret_ref = 0;
43581 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43582 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43583 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43584 ret_ref = (uintptr_t)ret_var.inner;
43585 if (ret_var.is_owned) {
43586         ret_ref |= 1;
43587 }
43588         return ret_ref;
43589 }
43590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43591         LDKChannelInfo arg_conv;
43592         arg_conv.inner = (void*)(arg & (~1));
43593         arg_conv.is_owned = false;
43594         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43595         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
43596         return ret_conv;
43597 }
43598
43599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43600         LDKChannelInfo orig_conv;
43601         orig_conv.inner = (void*)(orig & (~1));
43602         orig_conv.is_owned = false;
43603         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43604         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
43605         int64_t ret_ref = 0;
43606         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43607         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43609         ret_ref = (uintptr_t)ret_var.inner;
43610         if (ret_var.is_owned) {
43611                 ret_ref |= 1;
43612         }
43613         return ret_ref;
43614 }
43615
43616 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) {
43617         LDKChannelInfo this_arg_conv;
43618         this_arg_conv.inner = (void*)(this_arg & (~1));
43619         this_arg_conv.is_owned = false;
43620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43621         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
43622         int64_t ret_ref = 0;
43623         if ((uintptr_t)ret_var.inner > 4096) {
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         }
43632         return ret_ref;
43633 }
43634
43635 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
43636         LDKChannelInfo obj_conv;
43637         obj_conv.inner = (void*)(obj & (~1));
43638         obj_conv.is_owned = false;
43639         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43640         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
43641         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43642         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43643         CVec_u8Z_free(ret_var);
43644         return ret_arr;
43645 }
43646
43647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43648         LDKu8slice ser_ref;
43649         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43650         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43651         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
43652         *ret_conv = ChannelInfo_read(ser_ref);
43653         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43654         return (int64_t)ret_conv;
43655 }
43656
43657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43658         LDKDirectedChannelInfo this_obj_conv;
43659         this_obj_conv.inner = (void*)(this_obj & (~1));
43660         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43662         DirectedChannelInfo_free(this_obj_conv);
43663 }
43664
43665 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
43666         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
43667 int64_t ret_ref = 0;
43668 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43669 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43670 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43671 ret_ref = (uintptr_t)ret_var.inner;
43672 if (ret_var.is_owned) {
43673         ret_ref |= 1;
43674 }
43675         return ret_ref;
43676 }
43677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43678         LDKDirectedChannelInfo arg_conv;
43679         arg_conv.inner = (void*)(arg & (~1));
43680         arg_conv.is_owned = false;
43681         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43682         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
43683         return ret_conv;
43684 }
43685
43686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43687         LDKDirectedChannelInfo orig_conv;
43688         orig_conv.inner = (void*)(orig & (~1));
43689         orig_conv.is_owned = false;
43690         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43691         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
43692         int64_t ret_ref = 0;
43693         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43694         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43696         ret_ref = (uintptr_t)ret_var.inner;
43697         if (ret_var.is_owned) {
43698                 ret_ref |= 1;
43699         }
43700         return ret_ref;
43701 }
43702
43703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
43704         LDKDirectedChannelInfo this_arg_conv;
43705         this_arg_conv.inner = (void*)(this_arg & (~1));
43706         this_arg_conv.is_owned = false;
43707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43708         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
43709         int64_t ret_ref = 0;
43710         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43711         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43713         ret_ref = (uintptr_t)ret_var.inner;
43714         if (ret_var.is_owned) {
43715                 ret_ref |= 1;
43716         }
43717         return ret_ref;
43718 }
43719
43720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1direction(JNIEnv *env, jclass clz, int64_t this_arg) {
43721         LDKDirectedChannelInfo this_arg_conv;
43722         this_arg_conv.inner = (void*)(this_arg & (~1));
43723         this_arg_conv.is_owned = false;
43724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43725         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
43726         int64_t ret_ref = 0;
43727         if ((uintptr_t)ret_var.inner > 4096) {
43728                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43729                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43731                 ret_ref = (uintptr_t)ret_var.inner;
43732                 if (ret_var.is_owned) {
43733                         ret_ref |= 1;
43734                 }
43735         }
43736         return ret_ref;
43737 }
43738
43739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
43740         LDKDirectedChannelInfo this_arg_conv;
43741         this_arg_conv.inner = (void*)(this_arg & (~1));
43742         this_arg_conv.is_owned = false;
43743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43744         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
43745         return ret_conv;
43746 }
43747
43748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
43749         LDKDirectedChannelInfo this_arg_conv;
43750         this_arg_conv.inner = (void*)(this_arg & (~1));
43751         this_arg_conv.is_owned = false;
43752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43753         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43754         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
43755         int64_t ret_ref = (uintptr_t)ret_copy;
43756         return ret_ref;
43757 }
43758
43759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
43760         if ((this_ptr & 1) != 0) return;
43761         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43762         CHECK_ACCESS(this_ptr_ptr);
43763         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
43764         FREE((void*)this_ptr);
43765         EffectiveCapacity_free(this_ptr_conv);
43766 }
43767
43768 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
43769         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43770         *ret_copy = EffectiveCapacity_clone(arg);
43771 int64_t ret_ref = (uintptr_t)ret_copy;
43772         return ret_ref;
43773 }
43774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43775         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
43776         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
43777         return ret_conv;
43778 }
43779
43780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43781         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
43782         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43783         *ret_copy = EffectiveCapacity_clone(orig_conv);
43784         int64_t ret_ref = (uintptr_t)ret_copy;
43785         return ret_ref;
43786 }
43787
43788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
43789         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43790         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
43791         int64_t ret_ref = (uintptr_t)ret_copy;
43792         return ret_ref;
43793 }
43794
43795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
43796         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43797         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
43798         int64_t ret_ref = (uintptr_t)ret_copy;
43799         return ret_ref;
43800 }
43801
43802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat, int64_t htlc_maximum_msat) {
43803         void* htlc_maximum_msat_ptr = (void*)(((uintptr_t)htlc_maximum_msat) & ~1);
43804         CHECK_ACCESS(htlc_maximum_msat_ptr);
43805         LDKCOption_u64Z htlc_maximum_msat_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_ptr);
43806         htlc_maximum_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat) & ~1));
43807         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43808         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat_conv);
43809         int64_t ret_ref = (uintptr_t)ret_copy;
43810         return ret_ref;
43811 }
43812
43813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
43814         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43815         *ret_copy = EffectiveCapacity_infinite();
43816         int64_t ret_ref = (uintptr_t)ret_copy;
43817         return ret_ref;
43818 }
43819
43820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
43821         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43822         *ret_copy = EffectiveCapacity_unknown();
43823         int64_t ret_ref = (uintptr_t)ret_copy;
43824         return ret_ref;
43825 }
43826
43827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
43828         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
43829         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
43830         return ret_conv;
43831 }
43832
43833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43834         LDKRoutingFees this_obj_conv;
43835         this_obj_conv.inner = (void*)(this_obj & (~1));
43836         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43838         RoutingFees_free(this_obj_conv);
43839 }
43840
43841 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43842         LDKRoutingFees this_ptr_conv;
43843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43844         this_ptr_conv.is_owned = false;
43845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43846         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
43847         return ret_conv;
43848 }
43849
43850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43851         LDKRoutingFees this_ptr_conv;
43852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43853         this_ptr_conv.is_owned = false;
43854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43855         RoutingFees_set_base_msat(&this_ptr_conv, val);
43856 }
43857
43858 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
43859         LDKRoutingFees this_ptr_conv;
43860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43861         this_ptr_conv.is_owned = false;
43862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43863         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
43864         return ret_conv;
43865 }
43866
43867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43868         LDKRoutingFees this_ptr_conv;
43869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43870         this_ptr_conv.is_owned = false;
43871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43872         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
43873 }
43874
43875 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) {
43876         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
43877         int64_t ret_ref = 0;
43878         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43879         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43881         ret_ref = (uintptr_t)ret_var.inner;
43882         if (ret_var.is_owned) {
43883                 ret_ref |= 1;
43884         }
43885         return ret_ref;
43886 }
43887
43888 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43889         LDKRoutingFees a_conv;
43890         a_conv.inner = (void*)(a & (~1));
43891         a_conv.is_owned = false;
43892         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43893         LDKRoutingFees b_conv;
43894         b_conv.inner = (void*)(b & (~1));
43895         b_conv.is_owned = false;
43896         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43897         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
43898         return ret_conv;
43899 }
43900
43901 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
43902         LDKRoutingFees ret_var = RoutingFees_clone(arg);
43903 int64_t ret_ref = 0;
43904 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43905 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43906 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43907 ret_ref = (uintptr_t)ret_var.inner;
43908 if (ret_var.is_owned) {
43909         ret_ref |= 1;
43910 }
43911         return ret_ref;
43912 }
43913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43914         LDKRoutingFees arg_conv;
43915         arg_conv.inner = (void*)(arg & (~1));
43916         arg_conv.is_owned = false;
43917         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43918         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
43919         return ret_conv;
43920 }
43921
43922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43923         LDKRoutingFees orig_conv;
43924         orig_conv.inner = (void*)(orig & (~1));
43925         orig_conv.is_owned = false;
43926         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43927         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
43928         int64_t ret_ref = 0;
43929         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43930         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43932         ret_ref = (uintptr_t)ret_var.inner;
43933         if (ret_var.is_owned) {
43934                 ret_ref |= 1;
43935         }
43936         return ret_ref;
43937 }
43938
43939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
43940         LDKRoutingFees o_conv;
43941         o_conv.inner = (void*)(o & (~1));
43942         o_conv.is_owned = false;
43943         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43944         int64_t ret_conv = RoutingFees_hash(&o_conv);
43945         return ret_conv;
43946 }
43947
43948 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
43949         LDKRoutingFees obj_conv;
43950         obj_conv.inner = (void*)(obj & (~1));
43951         obj_conv.is_owned = false;
43952         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43953         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
43954         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43955         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43956         CVec_u8Z_free(ret_var);
43957         return ret_arr;
43958 }
43959
43960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43961         LDKu8slice ser_ref;
43962         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43963         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43964         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
43965         *ret_conv = RoutingFees_read(ser_ref);
43966         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43967         return (int64_t)ret_conv;
43968 }
43969
43970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43971         LDKNodeAnnouncementInfo this_obj_conv;
43972         this_obj_conv.inner = (void*)(this_obj & (~1));
43973         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43975         NodeAnnouncementInfo_free(this_obj_conv);
43976 }
43977
43978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
43979         LDKNodeAnnouncementInfo this_ptr_conv;
43980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43981         this_ptr_conv.is_owned = false;
43982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43983         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
43984         int64_t ret_ref = 0;
43985         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43986         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43988         ret_ref = (uintptr_t)ret_var.inner;
43989         if (ret_var.is_owned) {
43990                 ret_ref |= 1;
43991         }
43992         return ret_ref;
43993 }
43994
43995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43996         LDKNodeAnnouncementInfo this_ptr_conv;
43997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43998         this_ptr_conv.is_owned = false;
43999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44000         LDKNodeFeatures val_conv;
44001         val_conv.inner = (void*)(val & (~1));
44002         val_conv.is_owned = (val & 1) || (val == 0);
44003         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44004         val_conv = NodeFeatures_clone(&val_conv);
44005         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
44006 }
44007
44008 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
44009         LDKNodeAnnouncementInfo this_ptr_conv;
44010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44011         this_ptr_conv.is_owned = false;
44012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44013         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
44014         return ret_conv;
44015 }
44016
44017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
44018         LDKNodeAnnouncementInfo this_ptr_conv;
44019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44020         this_ptr_conv.is_owned = false;
44021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44022         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
44023 }
44024
44025 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
44026         LDKNodeAnnouncementInfo this_ptr_conv;
44027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44028         this_ptr_conv.is_owned = false;
44029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44030         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
44031         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
44032         return ret_arr;
44033 }
44034
44035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44036         LDKNodeAnnouncementInfo this_ptr_conv;
44037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44038         this_ptr_conv.is_owned = false;
44039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44040         LDKThreeBytes val_ref;
44041         CHECK((*env)->GetArrayLength(env, val) == 3);
44042         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
44043         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
44044 }
44045
44046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
44047         LDKNodeAnnouncementInfo this_ptr_conv;
44048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44049         this_ptr_conv.is_owned = false;
44050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44051         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
44052         int64_t ret_ref = 0;
44053         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44054         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44056         ret_ref = (uintptr_t)ret_var.inner;
44057         if (ret_var.is_owned) {
44058                 ret_ref |= 1;
44059         }
44060         return ret_ref;
44061 }
44062
44063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44064         LDKNodeAnnouncementInfo this_ptr_conv;
44065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44066         this_ptr_conv.is_owned = false;
44067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44068         LDKNodeAlias val_conv;
44069         val_conv.inner = (void*)(val & (~1));
44070         val_conv.is_owned = (val & 1) || (val == 0);
44071         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44072         val_conv = NodeAlias_clone(&val_conv);
44073         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
44074 }
44075
44076 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
44077         LDKNodeAnnouncementInfo this_ptr_conv;
44078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44079         this_ptr_conv.is_owned = false;
44080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44081         LDKCVec_NetAddressZ ret_var = NodeAnnouncementInfo_get_addresses(&this_ptr_conv);
44082         int64_tArray ret_arr = NULL;
44083         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44084         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44085         for (size_t m = 0; m < ret_var.datalen; m++) {
44086                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
44087                 *ret_conv_12_copy = ret_var.data[m];
44088                 int64_t ret_conv_12_ref = (uintptr_t)ret_conv_12_copy;
44089                 ret_arr_ptr[m] = ret_conv_12_ref;
44090         }
44091         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44092         FREE(ret_var.data);
44093         return ret_arr;
44094 }
44095
44096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
44097         LDKNodeAnnouncementInfo this_ptr_conv;
44098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44099         this_ptr_conv.is_owned = false;
44100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44101         LDKCVec_NetAddressZ val_constr;
44102         val_constr.datalen = (*env)->GetArrayLength(env, val);
44103         if (val_constr.datalen > 0)
44104                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
44105         else
44106                 val_constr.data = NULL;
44107         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
44108         for (size_t m = 0; m < val_constr.datalen; m++) {
44109                 int64_t val_conv_12 = val_vals[m];
44110                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
44111                 CHECK_ACCESS(val_conv_12_ptr);
44112                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
44113                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
44114                 val_constr.data[m] = val_conv_12_conv;
44115         }
44116         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
44117         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
44118 }
44119
44120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
44121         LDKNodeAnnouncementInfo this_ptr_conv;
44122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44123         this_ptr_conv.is_owned = false;
44124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44125         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
44126         int64_t ret_ref = 0;
44127         if ((uintptr_t)ret_var.inner > 4096) {
44128                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44129                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44131                 ret_ref = (uintptr_t)ret_var.inner;
44132                 if (ret_var.is_owned) {
44133                         ret_ref |= 1;
44134                 }
44135         }
44136         return ret_ref;
44137 }
44138
44139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44140         LDKNodeAnnouncementInfo this_ptr_conv;
44141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44142         this_ptr_conv.is_owned = false;
44143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44144         LDKNodeAnnouncement val_conv;
44145         val_conv.inner = (void*)(val & (~1));
44146         val_conv.is_owned = (val & 1) || (val == 0);
44147         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44148         val_conv = NodeAnnouncement_clone(&val_conv);
44149         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
44150 }
44151
44152 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, int64_t alias_arg, int64_tArray addresses_arg, int64_t announcement_message_arg) {
44153         LDKNodeFeatures features_arg_conv;
44154         features_arg_conv.inner = (void*)(features_arg & (~1));
44155         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
44156         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
44157         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
44158         LDKThreeBytes rgb_arg_ref;
44159         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
44160         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
44161         LDKNodeAlias alias_arg_conv;
44162         alias_arg_conv.inner = (void*)(alias_arg & (~1));
44163         alias_arg_conv.is_owned = (alias_arg & 1) || (alias_arg == 0);
44164         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
44165         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
44166         LDKCVec_NetAddressZ addresses_arg_constr;
44167         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
44168         if (addresses_arg_constr.datalen > 0)
44169                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
44170         else
44171                 addresses_arg_constr.data = NULL;
44172         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
44173         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
44174                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
44175                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
44176                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
44177                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
44178                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
44179         }
44180         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
44181         LDKNodeAnnouncement announcement_message_arg_conv;
44182         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
44183         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
44184         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
44185         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
44186         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
44187         int64_t ret_ref = 0;
44188         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44189         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44191         ret_ref = (uintptr_t)ret_var.inner;
44192         if (ret_var.is_owned) {
44193                 ret_ref |= 1;
44194         }
44195         return ret_ref;
44196 }
44197
44198 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
44199         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
44200 int64_t ret_ref = 0;
44201 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44202 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44203 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44204 ret_ref = (uintptr_t)ret_var.inner;
44205 if (ret_var.is_owned) {
44206         ret_ref |= 1;
44207 }
44208         return ret_ref;
44209 }
44210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44211         LDKNodeAnnouncementInfo arg_conv;
44212         arg_conv.inner = (void*)(arg & (~1));
44213         arg_conv.is_owned = false;
44214         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44215         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
44216         return ret_conv;
44217 }
44218
44219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44220         LDKNodeAnnouncementInfo orig_conv;
44221         orig_conv.inner = (void*)(orig & (~1));
44222         orig_conv.is_owned = false;
44223         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44224         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
44225         int64_t ret_ref = 0;
44226         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44227         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44229         ret_ref = (uintptr_t)ret_var.inner;
44230         if (ret_var.is_owned) {
44231                 ret_ref |= 1;
44232         }
44233         return ret_ref;
44234 }
44235
44236 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
44237         LDKNodeAnnouncementInfo obj_conv;
44238         obj_conv.inner = (void*)(obj & (~1));
44239         obj_conv.is_owned = false;
44240         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44241         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
44242         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44243         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44244         CVec_u8Z_free(ret_var);
44245         return ret_arr;
44246 }
44247
44248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44249         LDKu8slice ser_ref;
44250         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44251         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44252         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
44253         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
44254         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44255         return (int64_t)ret_conv;
44256 }
44257
44258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44259         LDKNodeAlias this_obj_conv;
44260         this_obj_conv.inner = (void*)(this_obj & (~1));
44261         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44263         NodeAlias_free(this_obj_conv);
44264 }
44265
44266 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
44267         LDKNodeAlias this_ptr_conv;
44268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44269         this_ptr_conv.is_owned = false;
44270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44271         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44272         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAlias_get_a(&this_ptr_conv));
44273         return ret_arr;
44274 }
44275
44276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44277         LDKNodeAlias this_ptr_conv;
44278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44279         this_ptr_conv.is_owned = false;
44280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44281         LDKThirtyTwoBytes val_ref;
44282         CHECK((*env)->GetArrayLength(env, val) == 32);
44283         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
44284         NodeAlias_set_a(&this_ptr_conv, val_ref);
44285 }
44286
44287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
44288         LDKThirtyTwoBytes a_arg_ref;
44289         CHECK((*env)->GetArrayLength(env, a_arg) == 32);
44290         (*env)->GetByteArrayRegion(env, a_arg, 0, 32, a_arg_ref.data);
44291         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
44292         int64_t ret_ref = 0;
44293         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44294         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44296         ret_ref = (uintptr_t)ret_var.inner;
44297         if (ret_var.is_owned) {
44298                 ret_ref |= 1;
44299         }
44300         return ret_ref;
44301 }
44302
44303 static inline uintptr_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
44304         LDKNodeAlias ret_var = NodeAlias_clone(arg);
44305 int64_t ret_ref = 0;
44306 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44307 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44308 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44309 ret_ref = (uintptr_t)ret_var.inner;
44310 if (ret_var.is_owned) {
44311         ret_ref |= 1;
44312 }
44313         return ret_ref;
44314 }
44315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44316         LDKNodeAlias arg_conv;
44317         arg_conv.inner = (void*)(arg & (~1));
44318         arg_conv.is_owned = false;
44319         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44320         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
44321         return ret_conv;
44322 }
44323
44324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44325         LDKNodeAlias orig_conv;
44326         orig_conv.inner = (void*)(orig & (~1));
44327         orig_conv.is_owned = false;
44328         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44329         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
44330         int64_t ret_ref = 0;
44331         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44332         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44334         ret_ref = (uintptr_t)ret_var.inner;
44335         if (ret_var.is_owned) {
44336                 ret_ref |= 1;
44337         }
44338         return ret_ref;
44339 }
44340
44341 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1write(JNIEnv *env, jclass clz, int64_t obj) {
44342         LDKNodeAlias obj_conv;
44343         obj_conv.inner = (void*)(obj & (~1));
44344         obj_conv.is_owned = false;
44345         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44346         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
44347         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44348         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44349         CVec_u8Z_free(ret_var);
44350         return ret_arr;
44351 }
44352
44353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44354         LDKu8slice ser_ref;
44355         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44356         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44357         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
44358         *ret_conv = NodeAlias_read(ser_ref);
44359         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44360         return (int64_t)ret_conv;
44361 }
44362
44363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44364         LDKNodeInfo this_obj_conv;
44365         this_obj_conv.inner = (void*)(this_obj & (~1));
44366         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44368         NodeInfo_free(this_obj_conv);
44369 }
44370
44371 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
44372         LDKNodeInfo this_ptr_conv;
44373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44374         this_ptr_conv.is_owned = false;
44375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44376         LDKCVec_u64Z ret_var = NodeInfo_get_channels(&this_ptr_conv);
44377         int64_tArray ret_arr = NULL;
44378         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44379         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44380         for (size_t g = 0; g < ret_var.datalen; g++) {
44381                 int64_t ret_conv_6_conv = ret_var.data[g];
44382                 ret_arr_ptr[g] = ret_conv_6_conv;
44383         }
44384         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44385         FREE(ret_var.data);
44386         return ret_arr;
44387 }
44388
44389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
44390         LDKNodeInfo this_ptr_conv;
44391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44392         this_ptr_conv.is_owned = false;
44393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44394         LDKCVec_u64Z val_constr;
44395         val_constr.datalen = (*env)->GetArrayLength(env, val);
44396         if (val_constr.datalen > 0)
44397                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
44398         else
44399                 val_constr.data = NULL;
44400         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
44401         for (size_t g = 0; g < val_constr.datalen; g++) {
44402                 int64_t val_conv_6 = val_vals[g];
44403                 val_constr.data[g] = val_conv_6;
44404         }
44405         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
44406         NodeInfo_set_channels(&this_ptr_conv, val_constr);
44407 }
44408
44409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
44410         LDKNodeInfo this_ptr_conv;
44411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44412         this_ptr_conv.is_owned = false;
44413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44414         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
44415         int64_t ret_ref = 0;
44416         if ((uintptr_t)ret_var.inner > 4096) {
44417                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44418                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44420                 ret_ref = (uintptr_t)ret_var.inner;
44421                 if (ret_var.is_owned) {
44422                         ret_ref |= 1;
44423                 }
44424         }
44425         return ret_ref;
44426 }
44427
44428 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) {
44429         LDKNodeInfo this_ptr_conv;
44430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44431         this_ptr_conv.is_owned = false;
44432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44433         LDKRoutingFees val_conv;
44434         val_conv.inner = (void*)(val & (~1));
44435         val_conv.is_owned = (val & 1) || (val == 0);
44436         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44437         val_conv = RoutingFees_clone(&val_conv);
44438         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
44439 }
44440
44441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
44442         LDKNodeInfo this_ptr_conv;
44443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44444         this_ptr_conv.is_owned = false;
44445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44446         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
44447         int64_t ret_ref = 0;
44448         if ((uintptr_t)ret_var.inner > 4096) {
44449                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44450                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44452                 ret_ref = (uintptr_t)ret_var.inner;
44453                 if (ret_var.is_owned) {
44454                         ret_ref |= 1;
44455                 }
44456         }
44457         return ret_ref;
44458 }
44459
44460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44461         LDKNodeInfo this_ptr_conv;
44462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44463         this_ptr_conv.is_owned = false;
44464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44465         LDKNodeAnnouncementInfo val_conv;
44466         val_conv.inner = (void*)(val & (~1));
44467         val_conv.is_owned = (val & 1) || (val == 0);
44468         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44469         val_conv = NodeAnnouncementInfo_clone(&val_conv);
44470         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
44471 }
44472
44473 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) {
44474         LDKCVec_u64Z channels_arg_constr;
44475         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
44476         if (channels_arg_constr.datalen > 0)
44477                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
44478         else
44479                 channels_arg_constr.data = NULL;
44480         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
44481         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
44482                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
44483                 channels_arg_constr.data[g] = channels_arg_conv_6;
44484         }
44485         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
44486         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
44487         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
44488         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
44489         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
44490         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
44491         LDKNodeAnnouncementInfo announcement_info_arg_conv;
44492         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
44493         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
44494         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
44495         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
44496         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
44497         int64_t ret_ref = 0;
44498         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44499         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44501         ret_ref = (uintptr_t)ret_var.inner;
44502         if (ret_var.is_owned) {
44503                 ret_ref |= 1;
44504         }
44505         return ret_ref;
44506 }
44507
44508 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
44509         LDKNodeInfo ret_var = NodeInfo_clone(arg);
44510 int64_t ret_ref = 0;
44511 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44512 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44513 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44514 ret_ref = (uintptr_t)ret_var.inner;
44515 if (ret_var.is_owned) {
44516         ret_ref |= 1;
44517 }
44518         return ret_ref;
44519 }
44520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44521         LDKNodeInfo arg_conv;
44522         arg_conv.inner = (void*)(arg & (~1));
44523         arg_conv.is_owned = false;
44524         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44525         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
44526         return ret_conv;
44527 }
44528
44529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44530         LDKNodeInfo orig_conv;
44531         orig_conv.inner = (void*)(orig & (~1));
44532         orig_conv.is_owned = false;
44533         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44534         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
44535         int64_t ret_ref = 0;
44536         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44537         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44538         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44539         ret_ref = (uintptr_t)ret_var.inner;
44540         if (ret_var.is_owned) {
44541                 ret_ref |= 1;
44542         }
44543         return ret_ref;
44544 }
44545
44546 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
44547         LDKNodeInfo obj_conv;
44548         obj_conv.inner = (void*)(obj & (~1));
44549         obj_conv.is_owned = false;
44550         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44551         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
44552         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44553         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44554         CVec_u8Z_free(ret_var);
44555         return ret_arr;
44556 }
44557
44558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44559         LDKu8slice ser_ref;
44560         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44561         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44562         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
44563         *ret_conv = NodeInfo_read(ser_ref);
44564         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44565         return (int64_t)ret_conv;
44566 }
44567
44568 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
44569         LDKNetworkGraph obj_conv;
44570         obj_conv.inner = (void*)(obj & (~1));
44571         obj_conv.is_owned = false;
44572         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44573         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
44574         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44575         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44576         CVec_u8Z_free(ret_var);
44577         return ret_arr;
44578 }
44579
44580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
44581         LDKu8slice ser_ref;
44582         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44583         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44584         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
44585         CHECK_ACCESS(arg_ptr);
44586         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
44587         if (arg_conv.free == LDKLogger_JCalls_free) {
44588                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44589                 LDKLogger_JCalls_cloned(&arg_conv);
44590         }
44591         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
44592         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
44593         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44594         return (int64_t)ret_conv;
44595 }
44596
44597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t logger) {
44598         LDKThirtyTwoBytes genesis_hash_ref;
44599         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
44600         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
44601         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
44602         CHECK_ACCESS(logger_ptr);
44603         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
44604         if (logger_conv.free == LDKLogger_JCalls_free) {
44605                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44606                 LDKLogger_JCalls_cloned(&logger_conv);
44607         }
44608         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
44609         int64_t ret_ref = 0;
44610         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44611         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44613         ret_ref = (uintptr_t)ret_var.inner;
44614         if (ret_var.is_owned) {
44615                 ret_ref |= 1;
44616         }
44617         return ret_ref;
44618 }
44619
44620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
44621         LDKNetworkGraph this_arg_conv;
44622         this_arg_conv.inner = (void*)(this_arg & (~1));
44623         this_arg_conv.is_owned = false;
44624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44625         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
44626         int64_t ret_ref = 0;
44627         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44628         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44630         ret_ref = (uintptr_t)ret_var.inner;
44631         if (ret_var.is_owned) {
44632                 ret_ref |= 1;
44633         }
44634         return ret_ref;
44635 }
44636
44637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1get_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
44638         LDKNetworkGraph this_arg_conv;
44639         this_arg_conv.inner = (void*)(this_arg & (~1));
44640         this_arg_conv.is_owned = false;
44641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44642         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
44643         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
44644         int64_t ret_ref = (uintptr_t)ret_copy;
44645         return ret_ref;
44646 }
44647
44648 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) {
44649         LDKNetworkGraph this_arg_conv;
44650         this_arg_conv.inner = (void*)(this_arg & (~1));
44651         this_arg_conv.is_owned = false;
44652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44653         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
44654 }
44655
44656 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) {
44657         LDKNetworkGraph this_arg_conv;
44658         this_arg_conv.inner = (void*)(this_arg & (~1));
44659         this_arg_conv.is_owned = false;
44660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44661         LDKNodeAnnouncement msg_conv;
44662         msg_conv.inner = (void*)(msg & (~1));
44663         msg_conv.is_owned = false;
44664         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44665         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44666         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
44667         return (int64_t)ret_conv;
44668 }
44669
44670 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) {
44671         LDKNetworkGraph this_arg_conv;
44672         this_arg_conv.inner = (void*)(this_arg & (~1));
44673         this_arg_conv.is_owned = false;
44674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44675         LDKUnsignedNodeAnnouncement msg_conv;
44676         msg_conv.inner = (void*)(msg & (~1));
44677         msg_conv.is_owned = false;
44678         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44679         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44680         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
44681         return (int64_t)ret_conv;
44682 }
44683
44684 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) {
44685         LDKNetworkGraph this_arg_conv;
44686         this_arg_conv.inner = (void*)(this_arg & (~1));
44687         this_arg_conv.is_owned = false;
44688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44689         LDKChannelAnnouncement msg_conv;
44690         msg_conv.inner = (void*)(msg & (~1));
44691         msg_conv.is_owned = false;
44692         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44693         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
44694         CHECK_ACCESS(chain_access_ptr);
44695         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
44696         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
44697         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
44698                 // Manually implement clone for Java trait instances
44699                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
44700                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44701                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
44702                 }
44703         }
44704         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44705         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
44706         return (int64_t)ret_conv;
44707 }
44708
44709 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) {
44710         LDKNetworkGraph this_arg_conv;
44711         this_arg_conv.inner = (void*)(this_arg & (~1));
44712         this_arg_conv.is_owned = false;
44713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44714         LDKUnsignedChannelAnnouncement msg_conv;
44715         msg_conv.inner = (void*)(msg & (~1));
44716         msg_conv.is_owned = false;
44717         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44718         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
44719         CHECK_ACCESS(chain_access_ptr);
44720         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
44721         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
44722         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
44723                 // Manually implement clone for Java trait instances
44724                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
44725                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44726                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
44727                 }
44728         }
44729         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44730         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
44731         return (int64_t)ret_conv;
44732 }
44733
44734 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) {
44735         LDKNetworkGraph this_arg_conv;
44736         this_arg_conv.inner = (void*)(this_arg & (~1));
44737         this_arg_conv.is_owned = false;
44738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44739         LDKChannelFeatures features_conv;
44740         features_conv.inner = (void*)(features & (~1));
44741         features_conv.is_owned = (features & 1) || (features == 0);
44742         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
44743         features_conv = ChannelFeatures_clone(&features_conv);
44744         LDKPublicKey node_id_1_ref;
44745         CHECK((*env)->GetArrayLength(env, node_id_1) == 33);
44746         (*env)->GetByteArrayRegion(env, node_id_1, 0, 33, node_id_1_ref.compressed_form);
44747         LDKPublicKey node_id_2_ref;
44748         CHECK((*env)->GetArrayLength(env, node_id_2) == 33);
44749         (*env)->GetByteArrayRegion(env, node_id_2, 0, 33, node_id_2_ref.compressed_form);
44750         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44751         *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);
44752         return (int64_t)ret_conv;
44753 }
44754
44755 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) {
44756         LDKNetworkGraph this_arg_conv;
44757         this_arg_conv.inner = (void*)(this_arg & (~1));
44758         this_arg_conv.is_owned = false;
44759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44760         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
44761 }
44762
44763 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) {
44764         LDKNetworkGraph this_arg_conv;
44765         this_arg_conv.inner = (void*)(this_arg & (~1));
44766         this_arg_conv.is_owned = false;
44767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44768         LDKPublicKey _node_id_ref;
44769         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
44770         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
44771         NetworkGraph_node_failed(&this_arg_conv, _node_id_ref, is_permanent);
44772 }
44773
44774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
44775         LDKNetworkGraph this_arg_conv;
44776         this_arg_conv.inner = (void*)(this_arg & (~1));
44777         this_arg_conv.is_owned = false;
44778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44779         NetworkGraph_remove_stale_channels(&this_arg_conv);
44780 }
44781
44782 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) {
44783         LDKNetworkGraph this_arg_conv;
44784         this_arg_conv.inner = (void*)(this_arg & (~1));
44785         this_arg_conv.is_owned = false;
44786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44787         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
44788 }
44789
44790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
44791         LDKNetworkGraph this_arg_conv;
44792         this_arg_conv.inner = (void*)(this_arg & (~1));
44793         this_arg_conv.is_owned = false;
44794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44795         LDKChannelUpdate msg_conv;
44796         msg_conv.inner = (void*)(msg & (~1));
44797         msg_conv.is_owned = false;
44798         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44799         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44800         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
44801         return (int64_t)ret_conv;
44802 }
44803
44804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
44805         LDKNetworkGraph this_arg_conv;
44806         this_arg_conv.inner = (void*)(this_arg & (~1));
44807         this_arg_conv.is_owned = false;
44808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44809         LDKUnsignedChannelUpdate msg_conv;
44810         msg_conv.inner = (void*)(msg & (~1));
44811         msg_conv.is_owned = false;
44812         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44813         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44814         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
44815         return (int64_t)ret_conv;
44816 }
44817
44818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
44819         LDKReadOnlyNetworkGraph this_arg_conv;
44820         this_arg_conv.inner = (void*)(this_arg & (~1));
44821         this_arg_conv.is_owned = false;
44822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44823         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
44824         int64_t ret_ref = 0;
44825         if ((uintptr_t)ret_var.inner > 4096) {
44826                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44827                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44829                 ret_ref = (uintptr_t)ret_var.inner;
44830                 if (ret_var.is_owned) {
44831                         ret_ref |= 1;
44832                 }
44833         }
44834         return ret_ref;
44835 }
44836
44837 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
44838         LDKReadOnlyNetworkGraph this_arg_conv;
44839         this_arg_conv.inner = (void*)(this_arg & (~1));
44840         this_arg_conv.is_owned = false;
44841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44842         LDKCVec_u64Z ret_var = ReadOnlyNetworkGraph_list_channels(&this_arg_conv);
44843         int64_tArray ret_arr = NULL;
44844         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44845         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44846         for (size_t g = 0; g < ret_var.datalen; g++) {
44847                 int64_t ret_conv_6_conv = ret_var.data[g];
44848                 ret_arr_ptr[g] = ret_conv_6_conv;
44849         }
44850         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44851         FREE(ret_var.data);
44852         return ret_arr;
44853 }
44854
44855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1node(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
44856         LDKReadOnlyNetworkGraph this_arg_conv;
44857         this_arg_conv.inner = (void*)(this_arg & (~1));
44858         this_arg_conv.is_owned = false;
44859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44860         LDKNodeId node_id_conv;
44861         node_id_conv.inner = (void*)(node_id & (~1));
44862         node_id_conv.is_owned = false;
44863         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
44864         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
44865         int64_t ret_ref = 0;
44866         if ((uintptr_t)ret_var.inner > 4096) {
44867                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44868                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44870                 ret_ref = (uintptr_t)ret_var.inner;
44871                 if (ret_var.is_owned) {
44872                         ret_ref |= 1;
44873                 }
44874         }
44875         return ret_ref;
44876 }
44877
44878 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1nodes(JNIEnv *env, jclass clz, int64_t this_arg) {
44879         LDKReadOnlyNetworkGraph this_arg_conv;
44880         this_arg_conv.inner = (void*)(this_arg & (~1));
44881         this_arg_conv.is_owned = false;
44882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44883         LDKCVec_NodeIdZ ret_var = ReadOnlyNetworkGraph_list_nodes(&this_arg_conv);
44884         int64_tArray ret_arr = NULL;
44885         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44886         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44887         for (size_t i = 0; i < ret_var.datalen; i++) {
44888                 LDKNodeId ret_conv_8_var = ret_var.data[i];
44889                 int64_t ret_conv_8_ref = 0;
44890                 CHECK((((uintptr_t)ret_conv_8_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44891                 CHECK((((uintptr_t)&ret_conv_8_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44892                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_8_var);
44893                 ret_conv_8_ref = (uintptr_t)ret_conv_8_var.inner;
44894                 if (ret_conv_8_var.is_owned) {
44895                         ret_conv_8_ref |= 1;
44896                 }
44897                 ret_arr_ptr[i] = ret_conv_8_ref;
44898         }
44899         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44900         FREE(ret_var.data);
44901         return ret_arr;
44902 }
44903
44904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
44905         LDKReadOnlyNetworkGraph this_arg_conv;
44906         this_arg_conv.inner = (void*)(this_arg & (~1));
44907         this_arg_conv.is_owned = false;
44908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44909         LDKPublicKey pubkey_ref;
44910         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
44911         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
44912         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
44913         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
44914         int64_t ret_ref = (uintptr_t)ret_copy;
44915         return ret_ref;
44916 }
44917
44918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44919         LDKRouteHop this_obj_conv;
44920         this_obj_conv.inner = (void*)(this_obj & (~1));
44921         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44923         RouteHop_free(this_obj_conv);
44924 }
44925
44926 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
44927         LDKRouteHop this_ptr_conv;
44928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44929         this_ptr_conv.is_owned = false;
44930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44931         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
44932         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
44933         return ret_arr;
44934 }
44935
44936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44937         LDKRouteHop this_ptr_conv;
44938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44939         this_ptr_conv.is_owned = false;
44940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44941         LDKPublicKey val_ref;
44942         CHECK((*env)->GetArrayLength(env, val) == 33);
44943         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
44944         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
44945 }
44946
44947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
44948         LDKRouteHop this_ptr_conv;
44949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44950         this_ptr_conv.is_owned = false;
44951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44952         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
44953         int64_t ret_ref = 0;
44954         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44955         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44957         ret_ref = (uintptr_t)ret_var.inner;
44958         if (ret_var.is_owned) {
44959                 ret_ref |= 1;
44960         }
44961         return ret_ref;
44962 }
44963
44964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44965         LDKRouteHop this_ptr_conv;
44966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44967         this_ptr_conv.is_owned = false;
44968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44969         LDKNodeFeatures val_conv;
44970         val_conv.inner = (void*)(val & (~1));
44971         val_conv.is_owned = (val & 1) || (val == 0);
44972         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44973         val_conv = NodeFeatures_clone(&val_conv);
44974         RouteHop_set_node_features(&this_ptr_conv, val_conv);
44975 }
44976
44977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
44978         LDKRouteHop this_ptr_conv;
44979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44980         this_ptr_conv.is_owned = false;
44981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44982         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
44983         return ret_conv;
44984 }
44985
44986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44987         LDKRouteHop this_ptr_conv;
44988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44989         this_ptr_conv.is_owned = false;
44990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44991         RouteHop_set_short_channel_id(&this_ptr_conv, val);
44992 }
44993
44994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
44995         LDKRouteHop this_ptr_conv;
44996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44997         this_ptr_conv.is_owned = false;
44998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44999         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
45000         int64_t ret_ref = 0;
45001         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45002         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45004         ret_ref = (uintptr_t)ret_var.inner;
45005         if (ret_var.is_owned) {
45006                 ret_ref |= 1;
45007         }
45008         return ret_ref;
45009 }
45010
45011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45012         LDKRouteHop this_ptr_conv;
45013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45014         this_ptr_conv.is_owned = false;
45015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45016         LDKChannelFeatures val_conv;
45017         val_conv.inner = (void*)(val & (~1));
45018         val_conv.is_owned = (val & 1) || (val == 0);
45019         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45020         val_conv = ChannelFeatures_clone(&val_conv);
45021         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
45022 }
45023
45024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45025         LDKRouteHop this_ptr_conv;
45026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45027         this_ptr_conv.is_owned = false;
45028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45029         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
45030         return ret_conv;
45031 }
45032
45033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45034         LDKRouteHop this_ptr_conv;
45035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45036         this_ptr_conv.is_owned = false;
45037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45038         RouteHop_set_fee_msat(&this_ptr_conv, val);
45039 }
45040
45041 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
45042         LDKRouteHop 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         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
45047         return ret_conv;
45048 }
45049
45050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
45051         LDKRouteHop this_ptr_conv;
45052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45053         this_ptr_conv.is_owned = false;
45054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45055         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
45056 }
45057
45058 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) {
45059         LDKPublicKey pubkey_arg_ref;
45060         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
45061         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
45062         LDKNodeFeatures node_features_arg_conv;
45063         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
45064         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
45065         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
45066         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
45067         LDKChannelFeatures channel_features_arg_conv;
45068         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
45069         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
45070         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
45071         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
45072         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);
45073         int64_t ret_ref = 0;
45074         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45075         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45077         ret_ref = (uintptr_t)ret_var.inner;
45078         if (ret_var.is_owned) {
45079                 ret_ref |= 1;
45080         }
45081         return ret_ref;
45082 }
45083
45084 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
45085         LDKRouteHop ret_var = RouteHop_clone(arg);
45086 int64_t ret_ref = 0;
45087 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45088 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45089 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45090 ret_ref = (uintptr_t)ret_var.inner;
45091 if (ret_var.is_owned) {
45092         ret_ref |= 1;
45093 }
45094         return ret_ref;
45095 }
45096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45097         LDKRouteHop arg_conv;
45098         arg_conv.inner = (void*)(arg & (~1));
45099         arg_conv.is_owned = false;
45100         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45101         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
45102         return ret_conv;
45103 }
45104
45105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45106         LDKRouteHop orig_conv;
45107         orig_conv.inner = (void*)(orig & (~1));
45108         orig_conv.is_owned = false;
45109         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45110         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
45111         int64_t ret_ref = 0;
45112         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45113         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45114         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45115         ret_ref = (uintptr_t)ret_var.inner;
45116         if (ret_var.is_owned) {
45117                 ret_ref |= 1;
45118         }
45119         return ret_ref;
45120 }
45121
45122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
45123         LDKRouteHop o_conv;
45124         o_conv.inner = (void*)(o & (~1));
45125         o_conv.is_owned = false;
45126         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45127         int64_t ret_conv = RouteHop_hash(&o_conv);
45128         return ret_conv;
45129 }
45130
45131 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45132         LDKRouteHop a_conv;
45133         a_conv.inner = (void*)(a & (~1));
45134         a_conv.is_owned = false;
45135         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45136         LDKRouteHop b_conv;
45137         b_conv.inner = (void*)(b & (~1));
45138         b_conv.is_owned = false;
45139         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45140         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
45141         return ret_conv;
45142 }
45143
45144 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
45145         LDKRouteHop obj_conv;
45146         obj_conv.inner = (void*)(obj & (~1));
45147         obj_conv.is_owned = false;
45148         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45149         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
45150         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45151         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45152         CVec_u8Z_free(ret_var);
45153         return ret_arr;
45154 }
45155
45156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45157         LDKu8slice ser_ref;
45158         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45159         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45160         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
45161         *ret_conv = RouteHop_read(ser_ref);
45162         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45163         return (int64_t)ret_conv;
45164 }
45165
45166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45167         LDKRoute this_obj_conv;
45168         this_obj_conv.inner = (void*)(this_obj & (~1));
45169         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45171         Route_free(this_obj_conv);
45172 }
45173
45174 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
45175         LDKRoute this_ptr_conv;
45176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45177         this_ptr_conv.is_owned = false;
45178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45179         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
45180         jobjectArray ret_arr = NULL;
45181         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
45182         ;
45183         for (size_t m = 0; m < ret_var.datalen; m++) {
45184                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
45185                 int64_tArray ret_conv_12_arr = NULL;
45186                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
45187                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
45188                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
45189                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
45190                         int64_t ret_conv_12_conv_10_ref = 0;
45191                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45192                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45193                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
45194                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
45195                         if (ret_conv_12_conv_10_var.is_owned) {
45196                                 ret_conv_12_conv_10_ref |= 1;
45197                         }
45198                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
45199                 }
45200                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
45201                 FREE(ret_conv_12_var.data);
45202                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
45203         }
45204         
45205         FREE(ret_var.data);
45206         return ret_arr;
45207 }
45208
45209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
45210         LDKRoute this_ptr_conv;
45211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45212         this_ptr_conv.is_owned = false;
45213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45214         LDKCVec_CVec_RouteHopZZ val_constr;
45215         val_constr.datalen = (*env)->GetArrayLength(env, val);
45216         if (val_constr.datalen > 0)
45217                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
45218         else
45219                 val_constr.data = NULL;
45220         for (size_t m = 0; m < val_constr.datalen; m++) {
45221                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
45222                 LDKCVec_RouteHopZ val_conv_12_constr;
45223                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
45224                 if (val_conv_12_constr.datalen > 0)
45225                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
45226                 else
45227                         val_conv_12_constr.data = NULL;
45228                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
45229                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
45230                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
45231                         LDKRouteHop val_conv_12_conv_10_conv;
45232                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
45233                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
45234                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
45235                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
45236                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
45237                 }
45238                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
45239                 val_constr.data[m] = val_conv_12_constr;
45240         }
45241         Route_set_paths(&this_ptr_conv, val_constr);
45242 }
45243
45244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
45245         LDKRoute this_ptr_conv;
45246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45247         this_ptr_conv.is_owned = false;
45248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45249         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
45250         int64_t ret_ref = 0;
45251         if ((uintptr_t)ret_var.inner > 4096) {
45252                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45253                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45255                 ret_ref = (uintptr_t)ret_var.inner;
45256                 if (ret_var.is_owned) {
45257                         ret_ref |= 1;
45258                 }
45259         }
45260         return ret_ref;
45261 }
45262
45263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45264         LDKRoute this_ptr_conv;
45265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45266         this_ptr_conv.is_owned = false;
45267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45268         LDKPaymentParameters val_conv;
45269         val_conv.inner = (void*)(val & (~1));
45270         val_conv.is_owned = (val & 1) || (val == 0);
45271         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45272         val_conv = PaymentParameters_clone(&val_conv);
45273         Route_set_payment_params(&this_ptr_conv, val_conv);
45274 }
45275
45276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
45277         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
45278         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
45279         if (paths_arg_constr.datalen > 0)
45280                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
45281         else
45282                 paths_arg_constr.data = NULL;
45283         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
45284                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
45285                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
45286                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
45287                 if (paths_arg_conv_12_constr.datalen > 0)
45288                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
45289                 else
45290                         paths_arg_conv_12_constr.data = NULL;
45291                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
45292                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
45293                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
45294                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
45295                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
45296                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
45297                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
45298                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
45299                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
45300                 }
45301                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
45302                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
45303         }
45304         LDKPaymentParameters payment_params_arg_conv;
45305         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
45306         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
45307         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
45308         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
45309         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
45310         int64_t ret_ref = 0;
45311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45314         ret_ref = (uintptr_t)ret_var.inner;
45315         if (ret_var.is_owned) {
45316                 ret_ref |= 1;
45317         }
45318         return ret_ref;
45319 }
45320
45321 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
45322         LDKRoute ret_var = Route_clone(arg);
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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45334         LDKRoute arg_conv;
45335         arg_conv.inner = (void*)(arg & (~1));
45336         arg_conv.is_owned = false;
45337         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45338         int64_t ret_conv = Route_clone_ptr(&arg_conv);
45339         return ret_conv;
45340 }
45341
45342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45343         LDKRoute orig_conv;
45344         orig_conv.inner = (void*)(orig & (~1));
45345         orig_conv.is_owned = false;
45346         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45347         LDKRoute ret_var = Route_clone(&orig_conv);
45348         int64_t ret_ref = 0;
45349         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45350         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45352         ret_ref = (uintptr_t)ret_var.inner;
45353         if (ret_var.is_owned) {
45354                 ret_ref |= 1;
45355         }
45356         return ret_ref;
45357 }
45358
45359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
45360         LDKRoute o_conv;
45361         o_conv.inner = (void*)(o & (~1));
45362         o_conv.is_owned = false;
45363         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45364         int64_t ret_conv = Route_hash(&o_conv);
45365         return ret_conv;
45366 }
45367
45368 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45369         LDKRoute a_conv;
45370         a_conv.inner = (void*)(a & (~1));
45371         a_conv.is_owned = false;
45372         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45373         LDKRoute b_conv;
45374         b_conv.inner = (void*)(b & (~1));
45375         b_conv.is_owned = false;
45376         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45377         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
45378         return ret_conv;
45379 }
45380
45381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
45382         LDKRoute this_arg_conv;
45383         this_arg_conv.inner = (void*)(this_arg & (~1));
45384         this_arg_conv.is_owned = false;
45385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45386         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
45387         return ret_conv;
45388 }
45389
45390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
45391         LDKRoute this_arg_conv;
45392         this_arg_conv.inner = (void*)(this_arg & (~1));
45393         this_arg_conv.is_owned = false;
45394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45395         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
45396         return ret_conv;
45397 }
45398
45399 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
45400         LDKRoute obj_conv;
45401         obj_conv.inner = (void*)(obj & (~1));
45402         obj_conv.is_owned = false;
45403         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45404         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
45405         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45406         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45407         CVec_u8Z_free(ret_var);
45408         return ret_arr;
45409 }
45410
45411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45412         LDKu8slice ser_ref;
45413         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45414         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45415         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
45416         *ret_conv = Route_read(ser_ref);
45417         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45418         return (int64_t)ret_conv;
45419 }
45420
45421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45422         LDKRouteParameters this_obj_conv;
45423         this_obj_conv.inner = (void*)(this_obj & (~1));
45424         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45426         RouteParameters_free(this_obj_conv);
45427 }
45428
45429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
45430         LDKRouteParameters this_ptr_conv;
45431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45432         this_ptr_conv.is_owned = false;
45433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45434         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
45435         int64_t ret_ref = 0;
45436         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45437         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45439         ret_ref = (uintptr_t)ret_var.inner;
45440         if (ret_var.is_owned) {
45441                 ret_ref |= 1;
45442         }
45443         return ret_ref;
45444 }
45445
45446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45447         LDKRouteParameters this_ptr_conv;
45448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45449         this_ptr_conv.is_owned = false;
45450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45451         LDKPaymentParameters val_conv;
45452         val_conv.inner = (void*)(val & (~1));
45453         val_conv.is_owned = (val & 1) || (val == 0);
45454         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45455         val_conv = PaymentParameters_clone(&val_conv);
45456         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
45457 }
45458
45459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45460         LDKRouteParameters this_ptr_conv;
45461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45462         this_ptr_conv.is_owned = false;
45463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45464         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
45465         return ret_conv;
45466 }
45467
45468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45469         LDKRouteParameters this_ptr_conv;
45470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45471         this_ptr_conv.is_owned = false;
45472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45473         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
45474 }
45475
45476 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
45477         LDKRouteParameters this_ptr_conv;
45478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45479         this_ptr_conv.is_owned = false;
45480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45481         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
45482         return ret_conv;
45483 }
45484
45485 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) {
45486         LDKRouteParameters this_ptr_conv;
45487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45488         this_ptr_conv.is_owned = false;
45489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45490         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
45491 }
45492
45493 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) {
45494         LDKPaymentParameters payment_params_arg_conv;
45495         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
45496         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
45497         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
45498         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
45499         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
45500         int64_t ret_ref = 0;
45501         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45502         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45504         ret_ref = (uintptr_t)ret_var.inner;
45505         if (ret_var.is_owned) {
45506                 ret_ref |= 1;
45507         }
45508         return ret_ref;
45509 }
45510
45511 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
45512         LDKRouteParameters ret_var = RouteParameters_clone(arg);
45513 int64_t ret_ref = 0;
45514 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45515 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45516 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45517 ret_ref = (uintptr_t)ret_var.inner;
45518 if (ret_var.is_owned) {
45519         ret_ref |= 1;
45520 }
45521         return ret_ref;
45522 }
45523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45524         LDKRouteParameters arg_conv;
45525         arg_conv.inner = (void*)(arg & (~1));
45526         arg_conv.is_owned = false;
45527         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45528         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
45529         return ret_conv;
45530 }
45531
45532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45533         LDKRouteParameters orig_conv;
45534         orig_conv.inner = (void*)(orig & (~1));
45535         orig_conv.is_owned = false;
45536         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45537         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
45538         int64_t ret_ref = 0;
45539         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45540         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45542         ret_ref = (uintptr_t)ret_var.inner;
45543         if (ret_var.is_owned) {
45544                 ret_ref |= 1;
45545         }
45546         return ret_ref;
45547 }
45548
45549 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
45550         LDKRouteParameters obj_conv;
45551         obj_conv.inner = (void*)(obj & (~1));
45552         obj_conv.is_owned = false;
45553         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45554         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
45555         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45556         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45557         CVec_u8Z_free(ret_var);
45558         return ret_arr;
45559 }
45560
45561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45562         LDKu8slice ser_ref;
45563         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45564         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45565         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
45566         *ret_conv = RouteParameters_read(ser_ref);
45567         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45568         return (int64_t)ret_conv;
45569 }
45570
45571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45572         LDKPaymentParameters this_obj_conv;
45573         this_obj_conv.inner = (void*)(this_obj & (~1));
45574         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45576         PaymentParameters_free(this_obj_conv);
45577 }
45578
45579 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
45580         LDKPaymentParameters this_ptr_conv;
45581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45582         this_ptr_conv.is_owned = false;
45583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45584         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
45585         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
45586         return ret_arr;
45587 }
45588
45589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
45590         LDKPaymentParameters this_ptr_conv;
45591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45592         this_ptr_conv.is_owned = false;
45593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45594         LDKPublicKey val_ref;
45595         CHECK((*env)->GetArrayLength(env, val) == 33);
45596         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
45597         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
45598 }
45599
45600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
45601         LDKPaymentParameters this_ptr_conv;
45602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45603         this_ptr_conv.is_owned = false;
45604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45605         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
45606         int64_t ret_ref = 0;
45607         if ((uintptr_t)ret_var.inner > 4096) {
45608                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45609                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45611                 ret_ref = (uintptr_t)ret_var.inner;
45612                 if (ret_var.is_owned) {
45613                         ret_ref |= 1;
45614                 }
45615         }
45616         return ret_ref;
45617 }
45618
45619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45620         LDKPaymentParameters this_ptr_conv;
45621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45622         this_ptr_conv.is_owned = false;
45623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45624         LDKInvoiceFeatures val_conv;
45625         val_conv.inner = (void*)(val & (~1));
45626         val_conv.is_owned = (val & 1) || (val == 0);
45627         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45628         val_conv = InvoiceFeatures_clone(&val_conv);
45629         PaymentParameters_set_features(&this_ptr_conv, val_conv);
45630 }
45631
45632 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
45633         LDKPaymentParameters this_ptr_conv;
45634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45635         this_ptr_conv.is_owned = false;
45636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45637         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
45638         int64_tArray ret_arr = NULL;
45639         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45640         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45641         for (size_t l = 0; l < ret_var.datalen; l++) {
45642                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
45643                 int64_t ret_conv_11_ref = 0;
45644                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45645                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45646                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
45647                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
45648                 if (ret_conv_11_var.is_owned) {
45649                         ret_conv_11_ref |= 1;
45650                 }
45651                 ret_arr_ptr[l] = ret_conv_11_ref;
45652         }
45653         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45654         FREE(ret_var.data);
45655         return ret_arr;
45656 }
45657
45658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
45659         LDKPaymentParameters this_ptr_conv;
45660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45661         this_ptr_conv.is_owned = false;
45662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45663         LDKCVec_RouteHintZ val_constr;
45664         val_constr.datalen = (*env)->GetArrayLength(env, val);
45665         if (val_constr.datalen > 0)
45666                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
45667         else
45668                 val_constr.data = NULL;
45669         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
45670         for (size_t l = 0; l < val_constr.datalen; l++) {
45671                 int64_t val_conv_11 = val_vals[l];
45672                 LDKRouteHint val_conv_11_conv;
45673                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
45674                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
45675                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
45676                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
45677                 val_constr.data[l] = val_conv_11_conv;
45678         }
45679         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
45680         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
45681 }
45682
45683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
45684         LDKPaymentParameters this_ptr_conv;
45685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45686         this_ptr_conv.is_owned = false;
45687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45688         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45689         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
45690         int64_t ret_ref = (uintptr_t)ret_copy;
45691         return ret_ref;
45692 }
45693
45694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45695         LDKPaymentParameters this_ptr_conv;
45696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45697         this_ptr_conv.is_owned = false;
45698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45699         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
45700         CHECK_ACCESS(val_ptr);
45701         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
45702         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
45703         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
45704 }
45705
45706 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
45707         LDKPaymentParameters this_ptr_conv;
45708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45709         this_ptr_conv.is_owned = false;
45710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45711         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
45712         return ret_conv;
45713 }
45714
45715 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) {
45716         LDKPaymentParameters this_ptr_conv;
45717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45718         this_ptr_conv.is_owned = false;
45719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45720         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
45721 }
45722
45723 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr) {
45724         LDKPaymentParameters this_ptr_conv;
45725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45726         this_ptr_conv.is_owned = false;
45727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45728         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
45729         return ret_conv;
45730 }
45731
45732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
45733         LDKPaymentParameters this_ptr_conv;
45734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45735         this_ptr_conv.is_owned = false;
45736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45737         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
45738 }
45739
45740 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1channel_1saturation_1power_1of_1half(JNIEnv *env, jclass clz, int64_t this_ptr) {
45741         LDKPaymentParameters this_ptr_conv;
45742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45743         this_ptr_conv.is_owned = false;
45744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45745         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
45746         return ret_conv;
45747 }
45748
45749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1channel_1saturation_1power_1of_1half(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
45750         LDKPaymentParameters this_ptr_conv;
45751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45752         this_ptr_conv.is_owned = false;
45753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45754         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
45755 }
45756
45757 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
45758         LDKPaymentParameters this_ptr_conv;
45759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45760         this_ptr_conv.is_owned = false;
45761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45762         LDKCVec_u64Z ret_var = PaymentParameters_get_previously_failed_channels(&this_ptr_conv);
45763         int64_tArray ret_arr = NULL;
45764         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45765         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45766         for (size_t g = 0; g < ret_var.datalen; g++) {
45767                 int64_t ret_conv_6_conv = ret_var.data[g];
45768                 ret_arr_ptr[g] = ret_conv_6_conv;
45769         }
45770         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45771         FREE(ret_var.data);
45772         return ret_arr;
45773 }
45774
45775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
45776         LDKPaymentParameters this_ptr_conv;
45777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45778         this_ptr_conv.is_owned = false;
45779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45780         LDKCVec_u64Z val_constr;
45781         val_constr.datalen = (*env)->GetArrayLength(env, val);
45782         if (val_constr.datalen > 0)
45783                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
45784         else
45785                 val_constr.data = NULL;
45786         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
45787         for (size_t g = 0; g < val_constr.datalen; g++) {
45788                 int64_t val_conv_6 = val_vals[g];
45789                 val_constr.data[g] = val_conv_6;
45790         }
45791         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
45792         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
45793 }
45794
45795 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, int8_t max_path_count_arg, int8_t max_channel_saturation_power_of_half_arg, int64_tArray previously_failed_channels_arg) {
45796         LDKPublicKey payee_pubkey_arg_ref;
45797         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
45798         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
45799         LDKInvoiceFeatures features_arg_conv;
45800         features_arg_conv.inner = (void*)(features_arg & (~1));
45801         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
45802         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
45803         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
45804         LDKCVec_RouteHintZ route_hints_arg_constr;
45805         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
45806         if (route_hints_arg_constr.datalen > 0)
45807                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
45808         else
45809                 route_hints_arg_constr.data = NULL;
45810         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
45811         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
45812                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
45813                 LDKRouteHint route_hints_arg_conv_11_conv;
45814                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
45815                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
45816                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
45817                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
45818                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
45819         }
45820         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
45821         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
45822         CHECK_ACCESS(expiry_time_arg_ptr);
45823         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
45824         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
45825         LDKCVec_u64Z previously_failed_channels_arg_constr;
45826         previously_failed_channels_arg_constr.datalen = (*env)->GetArrayLength(env, previously_failed_channels_arg);
45827         if (previously_failed_channels_arg_constr.datalen > 0)
45828                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
45829         else
45830                 previously_failed_channels_arg_constr.data = NULL;
45831         int64_t* previously_failed_channels_arg_vals = (*env)->GetLongArrayElements (env, previously_failed_channels_arg, NULL);
45832         for (size_t g = 0; g < previously_failed_channels_arg_constr.datalen; g++) {
45833                 int64_t previously_failed_channels_arg_conv_6 = previously_failed_channels_arg_vals[g];
45834                 previously_failed_channels_arg_constr.data[g] = previously_failed_channels_arg_conv_6;
45835         }
45836         (*env)->ReleaseLongArrayElements(env, previously_failed_channels_arg, previously_failed_channels_arg_vals, 0);
45837         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, max_path_count_arg, max_channel_saturation_power_of_half_arg, previously_failed_channels_arg_constr);
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
45849 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
45850         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
45851 int64_t ret_ref = 0;
45852 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45853 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45854 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45855 ret_ref = (uintptr_t)ret_var.inner;
45856 if (ret_var.is_owned) {
45857         ret_ref |= 1;
45858 }
45859         return ret_ref;
45860 }
45861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45862         LDKPaymentParameters arg_conv;
45863         arg_conv.inner = (void*)(arg & (~1));
45864         arg_conv.is_owned = false;
45865         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45866         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
45867         return ret_conv;
45868 }
45869
45870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45871         LDKPaymentParameters orig_conv;
45872         orig_conv.inner = (void*)(orig & (~1));
45873         orig_conv.is_owned = false;
45874         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45875         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
45876         int64_t ret_ref = 0;
45877         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45878         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45880         ret_ref = (uintptr_t)ret_var.inner;
45881         if (ret_var.is_owned) {
45882                 ret_ref |= 1;
45883         }
45884         return ret_ref;
45885 }
45886
45887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
45888         LDKPaymentParameters o_conv;
45889         o_conv.inner = (void*)(o & (~1));
45890         o_conv.is_owned = false;
45891         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45892         int64_t ret_conv = PaymentParameters_hash(&o_conv);
45893         return ret_conv;
45894 }
45895
45896 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45897         LDKPaymentParameters a_conv;
45898         a_conv.inner = (void*)(a & (~1));
45899         a_conv.is_owned = false;
45900         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45901         LDKPaymentParameters b_conv;
45902         b_conv.inner = (void*)(b & (~1));
45903         b_conv.is_owned = false;
45904         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45905         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
45906         return ret_conv;
45907 }
45908
45909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
45910         LDKPaymentParameters obj_conv;
45911         obj_conv.inner = (void*)(obj & (~1));
45912         obj_conv.is_owned = false;
45913         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45914         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
45915         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45916         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45917         CVec_u8Z_free(ret_var);
45918         return ret_arr;
45919 }
45920
45921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45922         LDKu8slice ser_ref;
45923         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45924         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45925         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
45926         *ret_conv = PaymentParameters_read(ser_ref);
45927         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45928         return (int64_t)ret_conv;
45929 }
45930
45931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
45932         LDKPublicKey payee_pubkey_ref;
45933         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
45934         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
45935         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
45936         int64_t ret_ref = 0;
45937         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45938         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45940         ret_ref = (uintptr_t)ret_var.inner;
45941         if (ret_var.is_owned) {
45942                 ret_ref |= 1;
45943         }
45944         return ret_ref;
45945 }
45946
45947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
45948         LDKPublicKey payee_pubkey_ref;
45949         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
45950         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
45951         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
45952         int64_t ret_ref = 0;
45953         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45954         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45956         ret_ref = (uintptr_t)ret_var.inner;
45957         if (ret_var.is_owned) {
45958                 ret_ref |= 1;
45959         }
45960         return ret_ref;
45961 }
45962
45963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45964         LDKRouteHint this_obj_conv;
45965         this_obj_conv.inner = (void*)(this_obj & (~1));
45966         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45968         RouteHint_free(this_obj_conv);
45969 }
45970
45971 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
45972         LDKRouteHint this_ptr_conv;
45973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45974         this_ptr_conv.is_owned = false;
45975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45976         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
45977         int64_tArray ret_arr = NULL;
45978         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45979         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45980         for (size_t o = 0; o < ret_var.datalen; o++) {
45981                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
45982                 int64_t ret_conv_14_ref = 0;
45983                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45984                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45985                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
45986                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
45987                 if (ret_conv_14_var.is_owned) {
45988                         ret_conv_14_ref |= 1;
45989                 }
45990                 ret_arr_ptr[o] = ret_conv_14_ref;
45991         }
45992         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45993         FREE(ret_var.data);
45994         return ret_arr;
45995 }
45996
45997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
45998         LDKRouteHint this_ptr_conv;
45999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46000         this_ptr_conv.is_owned = false;
46001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46002         LDKCVec_RouteHintHopZ val_constr;
46003         val_constr.datalen = (*env)->GetArrayLength(env, val);
46004         if (val_constr.datalen > 0)
46005                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
46006         else
46007                 val_constr.data = NULL;
46008         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
46009         for (size_t o = 0; o < val_constr.datalen; o++) {
46010                 int64_t val_conv_14 = val_vals[o];
46011                 LDKRouteHintHop val_conv_14_conv;
46012                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
46013                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
46014                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
46015                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
46016                 val_constr.data[o] = val_conv_14_conv;
46017         }
46018         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
46019         RouteHint_set_a(&this_ptr_conv, val_constr);
46020 }
46021
46022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
46023         LDKCVec_RouteHintHopZ a_arg_constr;
46024         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
46025         if (a_arg_constr.datalen > 0)
46026                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
46027         else
46028                 a_arg_constr.data = NULL;
46029         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
46030         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
46031                 int64_t a_arg_conv_14 = a_arg_vals[o];
46032                 LDKRouteHintHop a_arg_conv_14_conv;
46033                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
46034                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
46035                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
46036                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
46037                 a_arg_constr.data[o] = a_arg_conv_14_conv;
46038         }
46039         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
46040         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
46041         int64_t ret_ref = 0;
46042         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46043         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46045         ret_ref = (uintptr_t)ret_var.inner;
46046         if (ret_var.is_owned) {
46047                 ret_ref |= 1;
46048         }
46049         return ret_ref;
46050 }
46051
46052 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
46053         LDKRouteHint ret_var = RouteHint_clone(arg);
46054 int64_t ret_ref = 0;
46055 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46056 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46057 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46058 ret_ref = (uintptr_t)ret_var.inner;
46059 if (ret_var.is_owned) {
46060         ret_ref |= 1;
46061 }
46062         return ret_ref;
46063 }
46064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46065         LDKRouteHint arg_conv;
46066         arg_conv.inner = (void*)(arg & (~1));
46067         arg_conv.is_owned = false;
46068         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46069         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
46070         return ret_conv;
46071 }
46072
46073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46074         LDKRouteHint orig_conv;
46075         orig_conv.inner = (void*)(orig & (~1));
46076         orig_conv.is_owned = false;
46077         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46078         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
46079         int64_t ret_ref = 0;
46080         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46081         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46083         ret_ref = (uintptr_t)ret_var.inner;
46084         if (ret_var.is_owned) {
46085                 ret_ref |= 1;
46086         }
46087         return ret_ref;
46088 }
46089
46090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
46091         LDKRouteHint o_conv;
46092         o_conv.inner = (void*)(o & (~1));
46093         o_conv.is_owned = false;
46094         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46095         int64_t ret_conv = RouteHint_hash(&o_conv);
46096         return ret_conv;
46097 }
46098
46099 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46100         LDKRouteHint a_conv;
46101         a_conv.inner = (void*)(a & (~1));
46102         a_conv.is_owned = false;
46103         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46104         LDKRouteHint b_conv;
46105         b_conv.inner = (void*)(b & (~1));
46106         b_conv.is_owned = false;
46107         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46108         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
46109         return ret_conv;
46110 }
46111
46112 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
46113         LDKRouteHint obj_conv;
46114         obj_conv.inner = (void*)(obj & (~1));
46115         obj_conv.is_owned = false;
46116         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46117         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
46118         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46119         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46120         CVec_u8Z_free(ret_var);
46121         return ret_arr;
46122 }
46123
46124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46125         LDKu8slice ser_ref;
46126         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46127         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46128         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
46129         *ret_conv = RouteHint_read(ser_ref);
46130         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46131         return (int64_t)ret_conv;
46132 }
46133
46134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46135         LDKRouteHintHop this_obj_conv;
46136         this_obj_conv.inner = (void*)(this_obj & (~1));
46137         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46139         RouteHintHop_free(this_obj_conv);
46140 }
46141
46142 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
46143         LDKRouteHintHop this_ptr_conv;
46144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46145         this_ptr_conv.is_owned = false;
46146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46147         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
46148         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
46149         return ret_arr;
46150 }
46151
46152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
46153         LDKRouteHintHop this_ptr_conv;
46154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46155         this_ptr_conv.is_owned = false;
46156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46157         LDKPublicKey val_ref;
46158         CHECK((*env)->GetArrayLength(env, val) == 33);
46159         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
46160         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
46161 }
46162
46163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
46164         LDKRouteHintHop this_ptr_conv;
46165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46166         this_ptr_conv.is_owned = false;
46167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46168         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
46169         return ret_conv;
46170 }
46171
46172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46173         LDKRouteHintHop this_ptr_conv;
46174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46175         this_ptr_conv.is_owned = false;
46176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46177         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
46178 }
46179
46180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
46181         LDKRouteHintHop this_ptr_conv;
46182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46183         this_ptr_conv.is_owned = false;
46184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46185         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
46186         int64_t ret_ref = 0;
46187         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46188         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46190         ret_ref = (uintptr_t)ret_var.inner;
46191         if (ret_var.is_owned) {
46192                 ret_ref |= 1;
46193         }
46194         return ret_ref;
46195 }
46196
46197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46198         LDKRouteHintHop this_ptr_conv;
46199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46200         this_ptr_conv.is_owned = false;
46201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46202         LDKRoutingFees val_conv;
46203         val_conv.inner = (void*)(val & (~1));
46204         val_conv.is_owned = (val & 1) || (val == 0);
46205         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46206         val_conv = RoutingFees_clone(&val_conv);
46207         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
46208 }
46209
46210 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
46211         LDKRouteHintHop this_ptr_conv;
46212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46213         this_ptr_conv.is_owned = false;
46214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46215         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
46216         return ret_conv;
46217 }
46218
46219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
46220         LDKRouteHintHop this_ptr_conv;
46221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46222         this_ptr_conv.is_owned = false;
46223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46224         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
46225 }
46226
46227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46228         LDKRouteHintHop this_ptr_conv;
46229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46230         this_ptr_conv.is_owned = false;
46231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46232         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
46233         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
46234         int64_t ret_ref = (uintptr_t)ret_copy;
46235         return ret_ref;
46236 }
46237
46238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46239         LDKRouteHintHop this_ptr_conv;
46240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46241         this_ptr_conv.is_owned = false;
46242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46243         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
46244         CHECK_ACCESS(val_ptr);
46245         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
46246         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
46247         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
46248 }
46249
46250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46251         LDKRouteHintHop this_ptr_conv;
46252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46253         this_ptr_conv.is_owned = false;
46254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46255         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
46256         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
46257         int64_t ret_ref = (uintptr_t)ret_copy;
46258         return ret_ref;
46259 }
46260
46261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46262         LDKRouteHintHop this_ptr_conv;
46263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46264         this_ptr_conv.is_owned = false;
46265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46266         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
46267         CHECK_ACCESS(val_ptr);
46268         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
46269         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
46270         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
46271 }
46272
46273 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) {
46274         LDKPublicKey src_node_id_arg_ref;
46275         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
46276         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
46277         LDKRoutingFees fees_arg_conv;
46278         fees_arg_conv.inner = (void*)(fees_arg & (~1));
46279         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
46280         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
46281         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
46282         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
46283         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
46284         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
46285         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
46286         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
46287         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
46288         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
46289         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
46290         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);
46291         int64_t ret_ref = 0;
46292         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46293         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46295         ret_ref = (uintptr_t)ret_var.inner;
46296         if (ret_var.is_owned) {
46297                 ret_ref |= 1;
46298         }
46299         return ret_ref;
46300 }
46301
46302 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
46303         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
46304 int64_t ret_ref = 0;
46305 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46306 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46307 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46308 ret_ref = (uintptr_t)ret_var.inner;
46309 if (ret_var.is_owned) {
46310         ret_ref |= 1;
46311 }
46312         return ret_ref;
46313 }
46314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46315         LDKRouteHintHop arg_conv;
46316         arg_conv.inner = (void*)(arg & (~1));
46317         arg_conv.is_owned = false;
46318         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46319         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
46320         return ret_conv;
46321 }
46322
46323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46324         LDKRouteHintHop orig_conv;
46325         orig_conv.inner = (void*)(orig & (~1));
46326         orig_conv.is_owned = false;
46327         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46328         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
46329         int64_t ret_ref = 0;
46330         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46331         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46333         ret_ref = (uintptr_t)ret_var.inner;
46334         if (ret_var.is_owned) {
46335                 ret_ref |= 1;
46336         }
46337         return ret_ref;
46338 }
46339
46340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
46341         LDKRouteHintHop o_conv;
46342         o_conv.inner = (void*)(o & (~1));
46343         o_conv.is_owned = false;
46344         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46345         int64_t ret_conv = RouteHintHop_hash(&o_conv);
46346         return ret_conv;
46347 }
46348
46349 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46350         LDKRouteHintHop a_conv;
46351         a_conv.inner = (void*)(a & (~1));
46352         a_conv.is_owned = false;
46353         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46354         LDKRouteHintHop b_conv;
46355         b_conv.inner = (void*)(b & (~1));
46356         b_conv.is_owned = false;
46357         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46358         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
46359         return ret_conv;
46360 }
46361
46362 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
46363         LDKRouteHintHop obj_conv;
46364         obj_conv.inner = (void*)(obj & (~1));
46365         obj_conv.is_owned = false;
46366         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46367         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
46368         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46369         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46370         CVec_u8Z_free(ret_var);
46371         return ret_arr;
46372 }
46373
46374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46375         LDKu8slice ser_ref;
46376         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46377         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46378         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
46379         *ret_conv = RouteHintHop_read(ser_ref);
46380         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46381         return (int64_t)ret_conv;
46382 }
46383
46384 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) {
46385         LDKPublicKey our_node_pubkey_ref;
46386         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
46387         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
46388         LDKRouteParameters route_params_conv;
46389         route_params_conv.inner = (void*)(route_params & (~1));
46390         route_params_conv.is_owned = false;
46391         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
46392         LDKNetworkGraph network_graph_conv;
46393         network_graph_conv.inner = (void*)(network_graph & (~1));
46394         network_graph_conv.is_owned = false;
46395         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46396         LDKCVec_ChannelDetailsZ first_hops_constr;
46397         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
46398         if (first_hops != NULL) {
46399                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
46400                 if (first_hops_constr.datalen > 0)
46401                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
46402                 else
46403                         first_hops_constr.data = NULL;
46404                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
46405                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
46406                         int64_t first_hops_conv_16 = first_hops_vals[q];
46407                         LDKChannelDetails first_hops_conv_16_conv;
46408                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
46409                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
46410                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
46411                         first_hops_constr.data[q] = first_hops_conv_16_conv;
46412                 }
46413                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
46414                 first_hops_ptr = &first_hops_constr;
46415         }
46416         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
46417         CHECK_ACCESS(logger_ptr);
46418         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46419         if (logger_conv.free == LDKLogger_JCalls_free) {
46420                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46421                 LDKLogger_JCalls_cloned(&logger_conv);
46422         }
46423         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
46424         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
46425         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
46426         unsigned char random_seed_bytes_arr[32];
46427         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
46428         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
46429         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
46430         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
46431         *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);
46432         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
46433         return (int64_t)ret_conv;
46434 }
46435
46436 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) {
46437         LDKPublicKey our_node_pubkey_ref;
46438         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
46439         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
46440         LDKCVec_PublicKeyZ hops_constr;
46441         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
46442         if (hops_constr.datalen > 0)
46443                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
46444         else
46445                 hops_constr.data = NULL;
46446         for (size_t i = 0; i < hops_constr.datalen; i++) {
46447                 int8_tArray hops_conv_8 = (*env)->GetObjectArrayElement(env, hops, i);
46448                 LDKPublicKey hops_conv_8_ref;
46449                 CHECK((*env)->GetArrayLength(env, hops_conv_8) == 33);
46450                 (*env)->GetByteArrayRegion(env, hops_conv_8, 0, 33, hops_conv_8_ref.compressed_form);
46451                 hops_constr.data[i] = hops_conv_8_ref;
46452         }
46453         LDKRouteParameters route_params_conv;
46454         route_params_conv.inner = (void*)(route_params & (~1));
46455         route_params_conv.is_owned = false;
46456         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
46457         LDKNetworkGraph network_graph_conv;
46458         network_graph_conv.inner = (void*)(network_graph & (~1));
46459         network_graph_conv.is_owned = false;
46460         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46461         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
46462         CHECK_ACCESS(logger_ptr);
46463         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46464         if (logger_conv.free == LDKLogger_JCalls_free) {
46465                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46466                 LDKLogger_JCalls_cloned(&logger_conv);
46467         }
46468         unsigned char random_seed_bytes_arr[32];
46469         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
46470         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
46471         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
46472         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
46473         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
46474         return (int64_t)ret_conv;
46475 }
46476
46477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46478         if ((this_ptr & 1) != 0) return;
46479         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
46480         CHECK_ACCESS(this_ptr_ptr);
46481         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
46482         FREE((void*)this_ptr);
46483         Score_free(this_ptr_conv);
46484 }
46485
46486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46487         if ((this_ptr & 1) != 0) return;
46488         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
46489         CHECK_ACCESS(this_ptr_ptr);
46490         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
46491         FREE((void*)this_ptr);
46492         LockableScore_free(this_ptr_conv);
46493 }
46494
46495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46496         LDKMultiThreadedLockableScore this_obj_conv;
46497         this_obj_conv.inner = (void*)(this_obj & (~1));
46498         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46500         MultiThreadedLockableScore_free(this_obj_conv);
46501 }
46502
46503 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
46504         LDKMultiThreadedLockableScore obj_conv;
46505         obj_conv.inner = (void*)(obj & (~1));
46506         obj_conv.is_owned = false;
46507         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46508         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
46509         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46510         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46511         CVec_u8Z_free(ret_var);
46512         return ret_arr;
46513 }
46514
46515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
46516         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
46517         CHECK_ACCESS(score_ptr);
46518         LDKScore score_conv = *(LDKScore*)(score_ptr);
46519         if (score_conv.free == LDKScore_JCalls_free) {
46520                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46521                 LDKScore_JCalls_cloned(&score_conv);
46522         }
46523         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
46524         int64_t ret_ref = 0;
46525         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46526         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46528         ret_ref = (uintptr_t)ret_var.inner;
46529         if (ret_var.is_owned) {
46530                 ret_ref |= 1;
46531         }
46532         return ret_ref;
46533 }
46534
46535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46536         LDKChannelUsage this_obj_conv;
46537         this_obj_conv.inner = (void*)(this_obj & (~1));
46538         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46540         ChannelUsage_free(this_obj_conv);
46541 }
46542
46543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46544         LDKChannelUsage this_ptr_conv;
46545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46546         this_ptr_conv.is_owned = false;
46547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46548         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
46549         return ret_conv;
46550 }
46551
46552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46553         LDKChannelUsage this_ptr_conv;
46554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46555         this_ptr_conv.is_owned = false;
46556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46557         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
46558 }
46559
46560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46561         LDKChannelUsage this_ptr_conv;
46562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46563         this_ptr_conv.is_owned = false;
46564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46565         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
46566         return ret_conv;
46567 }
46568
46569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46570         LDKChannelUsage this_ptr_conv;
46571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46572         this_ptr_conv.is_owned = false;
46573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46574         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
46575 }
46576
46577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr) {
46578         LDKChannelUsage this_ptr_conv;
46579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46580         this_ptr_conv.is_owned = false;
46581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46582         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46583         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
46584         int64_t ret_ref = (uintptr_t)ret_copy;
46585         return ret_ref;
46586 }
46587
46588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46589         LDKChannelUsage this_ptr_conv;
46590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46591         this_ptr_conv.is_owned = false;
46592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46593         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
46594         CHECK_ACCESS(val_ptr);
46595         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
46596         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)val) & ~1));
46597         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
46598 }
46599
46600 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) {
46601         void* effective_capacity_arg_ptr = (void*)(((uintptr_t)effective_capacity_arg) & ~1);
46602         CHECK_ACCESS(effective_capacity_arg_ptr);
46603         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
46604         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)effective_capacity_arg) & ~1));
46605         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
46606         int64_t ret_ref = 0;
46607         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46608         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46610         ret_ref = (uintptr_t)ret_var.inner;
46611         if (ret_var.is_owned) {
46612                 ret_ref |= 1;
46613         }
46614         return ret_ref;
46615 }
46616
46617 static inline uintptr_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
46618         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
46619 int64_t ret_ref = 0;
46620 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46621 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46622 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46623 ret_ref = (uintptr_t)ret_var.inner;
46624 if (ret_var.is_owned) {
46625         ret_ref |= 1;
46626 }
46627         return ret_ref;
46628 }
46629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46630         LDKChannelUsage arg_conv;
46631         arg_conv.inner = (void*)(arg & (~1));
46632         arg_conv.is_owned = false;
46633         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46634         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
46635         return ret_conv;
46636 }
46637
46638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46639         LDKChannelUsage orig_conv;
46640         orig_conv.inner = (void*)(orig & (~1));
46641         orig_conv.is_owned = false;
46642         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46643         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
46644         int64_t ret_ref = 0;
46645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46648         ret_ref = (uintptr_t)ret_var.inner;
46649         if (ret_var.is_owned) {
46650                 ret_ref |= 1;
46651         }
46652         return ret_ref;
46653 }
46654
46655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46656         LDKFixedPenaltyScorer this_obj_conv;
46657         this_obj_conv.inner = (void*)(this_obj & (~1));
46658         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46660         FixedPenaltyScorer_free(this_obj_conv);
46661 }
46662
46663 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
46664         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
46665 int64_t ret_ref = 0;
46666 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46667 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46668 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46669 ret_ref = (uintptr_t)ret_var.inner;
46670 if (ret_var.is_owned) {
46671         ret_ref |= 1;
46672 }
46673         return ret_ref;
46674 }
46675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46676         LDKFixedPenaltyScorer arg_conv;
46677         arg_conv.inner = (void*)(arg & (~1));
46678         arg_conv.is_owned = false;
46679         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46680         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
46681         return ret_conv;
46682 }
46683
46684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46685         LDKFixedPenaltyScorer orig_conv;
46686         orig_conv.inner = (void*)(orig & (~1));
46687         orig_conv.is_owned = false;
46688         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46689         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
46690         int64_t ret_ref = 0;
46691         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46692         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46694         ret_ref = (uintptr_t)ret_var.inner;
46695         if (ret_var.is_owned) {
46696                 ret_ref |= 1;
46697         }
46698         return ret_ref;
46699 }
46700
46701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
46702         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
46703         int64_t ret_ref = 0;
46704         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46705         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46707         ret_ref = (uintptr_t)ret_var.inner;
46708         if (ret_var.is_owned) {
46709                 ret_ref |= 1;
46710         }
46711         return ret_ref;
46712 }
46713
46714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
46715         LDKFixedPenaltyScorer this_arg_conv;
46716         this_arg_conv.inner = (void*)(this_arg & (~1));
46717         this_arg_conv.is_owned = false;
46718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46719         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
46720         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
46721         return (int64_t)ret_ret;
46722 }
46723
46724 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
46725         LDKFixedPenaltyScorer obj_conv;
46726         obj_conv.inner = (void*)(obj & (~1));
46727         obj_conv.is_owned = false;
46728         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46729         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
46730         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46731         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46732         CVec_u8Z_free(ret_var);
46733         return ret_arr;
46734 }
46735
46736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
46737         LDKu8slice ser_ref;
46738         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46739         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46740         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
46741         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
46742         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46743         return (int64_t)ret_conv;
46744 }
46745
46746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46747         LDKProbabilisticScorer this_obj_conv;
46748         this_obj_conv.inner = (void*)(this_obj & (~1));
46749         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46751         ProbabilisticScorer_free(this_obj_conv);
46752 }
46753
46754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46755         LDKProbabilisticScoringParameters this_obj_conv;
46756         this_obj_conv.inner = (void*)(this_obj & (~1));
46757         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46759         ProbabilisticScoringParameters_free(this_obj_conv);
46760 }
46761
46762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46763         LDKProbabilisticScoringParameters this_ptr_conv;
46764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46765         this_ptr_conv.is_owned = false;
46766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46767         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
46768         return ret_conv;
46769 }
46770
46771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46772         LDKProbabilisticScoringParameters this_ptr_conv;
46773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46774         this_ptr_conv.is_owned = false;
46775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46776         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
46777 }
46778
46779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46780         LDKProbabilisticScoringParameters this_ptr_conv;
46781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46782         this_ptr_conv.is_owned = false;
46783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46784         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
46785         return ret_conv;
46786 }
46787
46788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46789         LDKProbabilisticScoringParameters this_ptr_conv;
46790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46791         this_ptr_conv.is_owned = false;
46792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46793         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
46794 }
46795
46796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46797         LDKProbabilisticScoringParameters this_ptr_conv;
46798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46799         this_ptr_conv.is_owned = false;
46800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46801         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
46802         return ret_conv;
46803 }
46804
46805 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) {
46806         LDKProbabilisticScoringParameters this_ptr_conv;
46807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46808         this_ptr_conv.is_owned = false;
46809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46810         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
46811 }
46812
46813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
46814         LDKProbabilisticScoringParameters this_ptr_conv;
46815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46816         this_ptr_conv.is_owned = false;
46817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46818         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
46819         return ret_conv;
46820 }
46821
46822 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) {
46823         LDKProbabilisticScoringParameters this_ptr_conv;
46824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46825         this_ptr_conv.is_owned = false;
46826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46827         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
46828 }
46829
46830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46831         LDKProbabilisticScoringParameters this_ptr_conv;
46832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46833         this_ptr_conv.is_owned = false;
46834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46835         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
46836         return ret_conv;
46837 }
46838
46839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46840         LDKProbabilisticScoringParameters this_ptr_conv;
46841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46842         this_ptr_conv.is_owned = false;
46843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46844         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
46845 }
46846
46847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46848         LDKProbabilisticScoringParameters this_ptr_conv;
46849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46850         this_ptr_conv.is_owned = false;
46851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46852         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
46853         return ret_conv;
46854 }
46855
46856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46857         LDKProbabilisticScoringParameters this_ptr_conv;
46858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46859         this_ptr_conv.is_owned = false;
46860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46861         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
46862 }
46863
46864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46865         LDKProbabilisticScoringParameters this_ptr_conv;
46866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46867         this_ptr_conv.is_owned = false;
46868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46869         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
46870         return ret_conv;
46871 }
46872
46873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46874         LDKProbabilisticScoringParameters this_ptr_conv;
46875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46876         this_ptr_conv.is_owned = false;
46877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46878         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
46879 }
46880
46881 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
46882         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
46883 int64_t ret_ref = 0;
46884 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46885 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46886 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46887 ret_ref = (uintptr_t)ret_var.inner;
46888 if (ret_var.is_owned) {
46889         ret_ref |= 1;
46890 }
46891         return ret_ref;
46892 }
46893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46894         LDKProbabilisticScoringParameters arg_conv;
46895         arg_conv.inner = (void*)(arg & (~1));
46896         arg_conv.is_owned = false;
46897         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46898         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
46899         return ret_conv;
46900 }
46901
46902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46903         LDKProbabilisticScoringParameters orig_conv;
46904         orig_conv.inner = (void*)(orig & (~1));
46905         orig_conv.is_owned = false;
46906         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46907         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
46908         int64_t ret_ref = 0;
46909         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46910         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46911         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46912         ret_ref = (uintptr_t)ret_var.inner;
46913         if (ret_var.is_owned) {
46914                 ret_ref |= 1;
46915         }
46916         return ret_ref;
46917 }
46918
46919 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) {
46920         LDKProbabilisticScoringParameters params_conv;
46921         params_conv.inner = (void*)(params & (~1));
46922         params_conv.is_owned = (params & 1) || (params == 0);
46923         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
46924         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
46925         LDKNetworkGraph network_graph_conv;
46926         network_graph_conv.inner = (void*)(network_graph & (~1));
46927         network_graph_conv.is_owned = false;
46928         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46929         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
46930         CHECK_ACCESS(logger_ptr);
46931         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46932         if (logger_conv.free == LDKLogger_JCalls_free) {
46933                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46934                 LDKLogger_JCalls_cloned(&logger_conv);
46935         }
46936         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
46937         int64_t ret_ref = 0;
46938         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46939         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46941         ret_ref = (uintptr_t)ret_var.inner;
46942         if (ret_var.is_owned) {
46943                 ret_ref |= 1;
46944         }
46945         return ret_ref;
46946 }
46947
46948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1debug_1log_1liquidity_1stats(JNIEnv *env, jclass clz, int64_t this_arg) {
46949         LDKProbabilisticScorer this_arg_conv;
46950         this_arg_conv.inner = (void*)(this_arg & (~1));
46951         this_arg_conv.is_owned = false;
46952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46953         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
46954 }
46955
46956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1estimated_1channel_1liquidity_1range(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scid, int64_t target) {
46957         LDKProbabilisticScorer this_arg_conv;
46958         this_arg_conv.inner = (void*)(this_arg & (~1));
46959         this_arg_conv.is_owned = false;
46960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46961         LDKNodeId target_conv;
46962         target_conv.inner = (void*)(target & (~1));
46963         target_conv.is_owned = false;
46964         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
46965         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
46966         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
46967         int64_t ret_ref = (uintptr_t)ret_copy;
46968         return ret_ref;
46969 }
46970
46971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1add_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
46972         LDKProbabilisticScorer this_arg_conv;
46973         this_arg_conv.inner = (void*)(this_arg & (~1));
46974         this_arg_conv.is_owned = false;
46975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46976         LDKNodeId node_id_conv;
46977         node_id_conv.inner = (void*)(node_id & (~1));
46978         node_id_conv.is_owned = false;
46979         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
46980         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
46981 }
46982
46983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
46984         LDKProbabilisticScorer 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         LDKNodeId node_id_conv;
46989         node_id_conv.inner = (void*)(node_id & (~1));
46990         node_id_conv.is_owned = false;
46991         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
46992         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
46993 }
46994
46995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1set_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id, int64_t penalty) {
46996         LDKProbabilisticScorer this_arg_conv;
46997         this_arg_conv.inner = (void*)(this_arg & (~1));
46998         this_arg_conv.is_owned = false;
46999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47000         LDKNodeId node_id_conv;
47001         node_id_conv.inner = (void*)(node_id & (~1));
47002         node_id_conv.is_owned = false;
47003         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
47004         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
47005 }
47006
47007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
47008         LDKProbabilisticScorer this_arg_conv;
47009         this_arg_conv.inner = (void*)(this_arg & (~1));
47010         this_arg_conv.is_owned = false;
47011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47012         LDKNodeId node_id_conv;
47013         node_id_conv.inner = (void*)(node_id & (~1));
47014         node_id_conv.is_owned = false;
47015         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
47016         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
47017 }
47018
47019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1clear_1manual_1penalties(JNIEnv *env, jclass clz, int64_t this_arg) {
47020         LDKProbabilisticScorer this_arg_conv;
47021         this_arg_conv.inner = (void*)(this_arg & (~1));
47022         this_arg_conv.is_owned = false;
47023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47024         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
47025 }
47026
47027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1add_1banned_1from_1list(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray node_ids) {
47028         LDKProbabilisticScoringParameters this_arg_conv;
47029         this_arg_conv.inner = (void*)(this_arg & (~1));
47030         this_arg_conv.is_owned = false;
47031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47032         LDKCVec_NodeIdZ node_ids_constr;
47033         node_ids_constr.datalen = (*env)->GetArrayLength(env, node_ids);
47034         if (node_ids_constr.datalen > 0)
47035                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
47036         else
47037                 node_ids_constr.data = NULL;
47038         int64_t* node_ids_vals = (*env)->GetLongArrayElements (env, node_ids, NULL);
47039         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
47040                 int64_t node_ids_conv_8 = node_ids_vals[i];
47041                 LDKNodeId node_ids_conv_8_conv;
47042                 node_ids_conv_8_conv.inner = (void*)(node_ids_conv_8 & (~1));
47043                 node_ids_conv_8_conv.is_owned = (node_ids_conv_8 & 1) || (node_ids_conv_8 == 0);
47044                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
47045                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
47046                 node_ids_constr.data[i] = node_ids_conv_8_conv;
47047         }
47048         (*env)->ReleaseLongArrayElements(env, node_ids, node_ids_vals, 0);
47049         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
47050 }
47051
47052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
47053         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
47054         int64_t ret_ref = 0;
47055         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47056         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47058         ret_ref = (uintptr_t)ret_var.inner;
47059         if (ret_var.is_owned) {
47060                 ret_ref |= 1;
47061         }
47062         return ret_ref;
47063 }
47064
47065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
47066         LDKProbabilisticScorer this_arg_conv;
47067         this_arg_conv.inner = (void*)(this_arg & (~1));
47068         this_arg_conv.is_owned = false;
47069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47070         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
47071         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
47072         return (int64_t)ret_ret;
47073 }
47074
47075 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
47076         LDKProbabilisticScorer obj_conv;
47077         obj_conv.inner = (void*)(obj & (~1));
47078         obj_conv.is_owned = false;
47079         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47080         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
47081         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47082         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47083         CVec_u8Z_free(ret_var);
47084         return ret_arr;
47085 }
47086
47087 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) {
47088         LDKu8slice ser_ref;
47089         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47090         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47091         LDKProbabilisticScoringParameters arg_a_conv;
47092         arg_a_conv.inner = (void*)(arg_a & (~1));
47093         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
47094         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
47095         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
47096         LDKNetworkGraph arg_b_conv;
47097         arg_b_conv.inner = (void*)(arg_b & (~1));
47098         arg_b_conv.is_owned = false;
47099         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
47100         void* arg_c_ptr = (void*)(((uintptr_t)arg_c) & ~1);
47101         CHECK_ACCESS(arg_c_ptr);
47102         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
47103         if (arg_c_conv.free == LDKLogger_JCalls_free) {
47104                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47105                 LDKLogger_JCalls_cloned(&arg_c_conv);
47106         }
47107         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
47108         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
47109         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47110         return (int64_t)ret_conv;
47111 }
47112
47113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47114         LDKFilesystemPersister this_obj_conv;
47115         this_obj_conv.inner = (void*)(this_obj & (~1));
47116         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47118         FilesystemPersister_free(this_obj_conv);
47119 }
47120
47121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
47122         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
47123         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
47124         int64_t ret_ref = 0;
47125         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47126         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47127         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47128         ret_ref = (uintptr_t)ret_var.inner;
47129         if (ret_var.is_owned) {
47130                 ret_ref |= 1;
47131         }
47132         return ret_ref;
47133 }
47134
47135 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
47136         LDKFilesystemPersister this_arg_conv;
47137         this_arg_conv.inner = (void*)(this_arg & (~1));
47138         this_arg_conv.is_owned = false;
47139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47140         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
47141         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47142         Str_free(ret_str);
47143         return ret_conv;
47144 }
47145
47146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
47147         LDKFilesystemPersister this_arg_conv;
47148         this_arg_conv.inner = (void*)(this_arg & (~1));
47149         this_arg_conv.is_owned = false;
47150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47151         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
47152         CHECK_ACCESS(keys_manager_ptr);
47153         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
47154         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
47155                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47156                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
47157         }
47158         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
47159         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
47160         return (int64_t)ret_conv;
47161 }
47162
47163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47164         LDKBackgroundProcessor this_obj_conv;
47165         this_obj_conv.inner = (void*)(this_obj & (~1));
47166         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47168         BackgroundProcessor_free(this_obj_conv);
47169 }
47170
47171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipSync_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47172         if ((this_ptr & 1) != 0) return;
47173         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
47174         CHECK_ACCESS(this_ptr_ptr);
47175         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
47176         FREE((void*)this_ptr);
47177         GossipSync_free(this_ptr_conv);
47178 }
47179
47180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1p2_1p(JNIEnv *env, jclass clz, int64_t a) {
47181         LDKP2PGossipSync a_conv;
47182         a_conv.inner = (void*)(a & (~1));
47183         a_conv.is_owned = false;
47184         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47185         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
47186         *ret_copy = GossipSync_p2_p(&a_conv);
47187         int64_t ret_ref = (uintptr_t)ret_copy;
47188         return ret_ref;
47189 }
47190
47191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1rapid(JNIEnv *env, jclass clz, int64_t a) {
47192         LDKRapidGossipSync a_conv;
47193         a_conv.inner = (void*)(a & (~1));
47194         a_conv.is_owned = false;
47195         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47196         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
47197         *ret_copy = GossipSync_rapid(&a_conv);
47198         int64_t ret_ref = (uintptr_t)ret_copy;
47199         return ret_ref;
47200 }
47201
47202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1none(JNIEnv *env, jclass clz) {
47203         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
47204         *ret_copy = GossipSync_none();
47205         int64_t ret_ref = (uintptr_t)ret_copy;
47206         return ret_ref;
47207 }
47208
47209 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) {
47210         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
47211         CHECK_ACCESS(persister_ptr);
47212         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
47213         if (persister_conv.free == LDKPersister_JCalls_free) {
47214                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47215                 LDKPersister_JCalls_cloned(&persister_conv);
47216         }
47217         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
47218         CHECK_ACCESS(event_handler_ptr);
47219         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
47220         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
47221                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47222                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
47223         }
47224         LDKChainMonitor chain_monitor_conv;
47225         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
47226         chain_monitor_conv.is_owned = false;
47227         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
47228         LDKChannelManager channel_manager_conv;
47229         channel_manager_conv.inner = (void*)(channel_manager & (~1));
47230         channel_manager_conv.is_owned = false;
47231         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
47232         void* gossip_sync_ptr = (void*)(((uintptr_t)gossip_sync) & ~1);
47233         CHECK_ACCESS(gossip_sync_ptr);
47234         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
47235         // WARNING: we may need a move here but no clone is available for LDKGossipSync
47236         LDKPeerManager peer_manager_conv;
47237         peer_manager_conv.inner = (void*)(peer_manager & (~1));
47238         peer_manager_conv.is_owned = false;
47239         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
47240         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
47241         CHECK_ACCESS(logger_ptr);
47242         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47243         if (logger_conv.free == LDKLogger_JCalls_free) {
47244                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47245                 LDKLogger_JCalls_cloned(&logger_conv);
47246         }
47247         LDKMultiThreadedLockableScore scorer_conv;
47248         scorer_conv.inner = (void*)(scorer & (~1));
47249         scorer_conv.is_owned = (scorer & 1) || (scorer == 0);
47250         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
47251         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);
47252         int64_t ret_ref = 0;
47253         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47254         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47256         ret_ref = (uintptr_t)ret_var.inner;
47257         if (ret_var.is_owned) {
47258                 ret_ref |= 1;
47259         }
47260         return ret_ref;
47261 }
47262
47263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
47264         LDKBackgroundProcessor this_arg_conv;
47265         this_arg_conv.inner = (void*)(this_arg & (~1));
47266         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
47267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47268         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
47269         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
47270         *ret_conv = BackgroundProcessor_join(this_arg_conv);
47271         return (int64_t)ret_conv;
47272 }
47273
47274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
47275         LDKBackgroundProcessor this_arg_conv;
47276         this_arg_conv.inner = (void*)(this_arg & (~1));
47277         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
47278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47279         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
47280         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
47281         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
47282         return (int64_t)ret_conv;
47283 }
47284
47285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47286         if ((this_ptr & 1) != 0) return;
47287         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
47288         CHECK_ACCESS(this_ptr_ptr);
47289         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
47290         FREE((void*)this_ptr);
47291         ParseError_free(this_ptr_conv);
47292 }
47293
47294 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
47295         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47296         *ret_copy = ParseError_clone(arg);
47297 int64_t ret_ref = (uintptr_t)ret_copy;
47298         return ret_ref;
47299 }
47300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47301         LDKParseError* arg_conv = (LDKParseError*)arg;
47302         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
47303         return ret_conv;
47304 }
47305
47306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47307         LDKParseError* orig_conv = (LDKParseError*)orig;
47308         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47309         *ret_copy = ParseError_clone(orig_conv);
47310         int64_t ret_ref = (uintptr_t)ret_copy;
47311         return ret_ref;
47312 }
47313
47314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
47315         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
47316         CHECK_ACCESS(a_ptr);
47317         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
47318         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
47319         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47320         *ret_copy = ParseError_bech32_error(a_conv);
47321         int64_t ret_ref = (uintptr_t)ret_copy;
47322         return ret_ref;
47323 }
47324
47325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
47326         
47327         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47328         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
47329         int64_t ret_ref = (uintptr_t)ret_copy;
47330         return ret_ref;
47331 }
47332
47333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
47334         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
47335         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47336         *ret_copy = ParseError_malformed_signature(a_conv);
47337         int64_t ret_ref = (uintptr_t)ret_copy;
47338         return ret_ref;
47339 }
47340
47341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
47342         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47343         *ret_copy = ParseError_bad_prefix();
47344         int64_t ret_ref = (uintptr_t)ret_copy;
47345         return ret_ref;
47346 }
47347
47348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
47349         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47350         *ret_copy = ParseError_unknown_currency();
47351         int64_t ret_ref = (uintptr_t)ret_copy;
47352         return ret_ref;
47353 }
47354
47355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
47356         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47357         *ret_copy = ParseError_unknown_si_prefix();
47358         int64_t ret_ref = (uintptr_t)ret_copy;
47359         return ret_ref;
47360 }
47361
47362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
47363         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47364         *ret_copy = ParseError_malformed_hrp();
47365         int64_t ret_ref = (uintptr_t)ret_copy;
47366         return ret_ref;
47367 }
47368
47369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
47370         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47371         *ret_copy = ParseError_too_short_data_part();
47372         int64_t ret_ref = (uintptr_t)ret_copy;
47373         return ret_ref;
47374 }
47375
47376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
47377         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47378         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
47379         int64_t ret_ref = (uintptr_t)ret_copy;
47380         return ret_ref;
47381 }
47382
47383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
47384         
47385         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47386         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
47387         int64_t ret_ref = (uintptr_t)ret_copy;
47388         return ret_ref;
47389 }
47390
47391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
47392         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47393         *ret_copy = ParseError_padding_error();
47394         int64_t ret_ref = (uintptr_t)ret_copy;
47395         return ret_ref;
47396 }
47397
47398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
47399         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47400         *ret_copy = ParseError_integer_overflow_error();
47401         int64_t ret_ref = (uintptr_t)ret_copy;
47402         return ret_ref;
47403 }
47404
47405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
47406         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47407         *ret_copy = ParseError_invalid_seg_wit_program_length();
47408         int64_t ret_ref = (uintptr_t)ret_copy;
47409         return ret_ref;
47410 }
47411
47412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
47413         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47414         *ret_copy = ParseError_invalid_pub_key_hash_length();
47415         int64_t ret_ref = (uintptr_t)ret_copy;
47416         return ret_ref;
47417 }
47418
47419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
47420         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47421         *ret_copy = ParseError_invalid_script_hash_length();
47422         int64_t ret_ref = (uintptr_t)ret_copy;
47423         return ret_ref;
47424 }
47425
47426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
47427         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47428         *ret_copy = ParseError_invalid_recovery_id();
47429         int64_t ret_ref = (uintptr_t)ret_copy;
47430         return ret_ref;
47431 }
47432
47433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
47434         LDKStr a_conv = java_to_owned_str(env, a);
47435         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47436         *ret_copy = ParseError_invalid_slice_length(a_conv);
47437         int64_t ret_ref = (uintptr_t)ret_copy;
47438         return ret_ref;
47439 }
47440
47441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
47442         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47443         *ret_copy = ParseError_skip();
47444         int64_t ret_ref = (uintptr_t)ret_copy;
47445         return ret_ref;
47446 }
47447
47448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47449         if ((this_ptr & 1) != 0) return;
47450         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
47451         CHECK_ACCESS(this_ptr_ptr);
47452         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
47453         FREE((void*)this_ptr);
47454         ParseOrSemanticError_free(this_ptr_conv);
47455 }
47456
47457 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
47458         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
47459         *ret_copy = ParseOrSemanticError_clone(arg);
47460 int64_t ret_ref = (uintptr_t)ret_copy;
47461         return ret_ref;
47462 }
47463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47464         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
47465         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
47466         return ret_conv;
47467 }
47468
47469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47470         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
47471         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
47472         *ret_copy = ParseOrSemanticError_clone(orig_conv);
47473         int64_t ret_ref = (uintptr_t)ret_copy;
47474         return ret_ref;
47475 }
47476
47477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
47478         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
47479         CHECK_ACCESS(a_ptr);
47480         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
47481         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
47482         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
47483         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
47484         int64_t ret_ref = (uintptr_t)ret_copy;
47485         return ret_ref;
47486 }
47487
47488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
47489         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
47490         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
47491         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
47492         int64_t ret_ref = (uintptr_t)ret_copy;
47493         return ret_ref;
47494 }
47495
47496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47497         LDKInvoice this_obj_conv;
47498         this_obj_conv.inner = (void*)(this_obj & (~1));
47499         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47501         Invoice_free(this_obj_conv);
47502 }
47503
47504 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47505         LDKInvoice a_conv;
47506         a_conv.inner = (void*)(a & (~1));
47507         a_conv.is_owned = false;
47508         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47509         LDKInvoice b_conv;
47510         b_conv.inner = (void*)(b & (~1));
47511         b_conv.is_owned = false;
47512         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47513         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
47514         return ret_conv;
47515 }
47516
47517 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
47518         LDKInvoice ret_var = Invoice_clone(arg);
47519 int64_t ret_ref = 0;
47520 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47521 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47522 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47523 ret_ref = (uintptr_t)ret_var.inner;
47524 if (ret_var.is_owned) {
47525         ret_ref |= 1;
47526 }
47527         return ret_ref;
47528 }
47529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47530         LDKInvoice arg_conv;
47531         arg_conv.inner = (void*)(arg & (~1));
47532         arg_conv.is_owned = false;
47533         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47534         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
47535         return ret_conv;
47536 }
47537
47538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47539         LDKInvoice orig_conv;
47540         orig_conv.inner = (void*)(orig & (~1));
47541         orig_conv.is_owned = false;
47542         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47543         LDKInvoice ret_var = Invoice_clone(&orig_conv);
47544         int64_t ret_ref = 0;
47545         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47546         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47548         ret_ref = (uintptr_t)ret_var.inner;
47549         if (ret_var.is_owned) {
47550                 ret_ref |= 1;
47551         }
47552         return ret_ref;
47553 }
47554
47555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47556         LDKSignedRawInvoice this_obj_conv;
47557         this_obj_conv.inner = (void*)(this_obj & (~1));
47558         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47560         SignedRawInvoice_free(this_obj_conv);
47561 }
47562
47563 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47564         LDKSignedRawInvoice a_conv;
47565         a_conv.inner = (void*)(a & (~1));
47566         a_conv.is_owned = false;
47567         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47568         LDKSignedRawInvoice b_conv;
47569         b_conv.inner = (void*)(b & (~1));
47570         b_conv.is_owned = false;
47571         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47572         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
47573         return ret_conv;
47574 }
47575
47576 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
47577         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
47578 int64_t ret_ref = 0;
47579 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47580 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47581 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47582 ret_ref = (uintptr_t)ret_var.inner;
47583 if (ret_var.is_owned) {
47584         ret_ref |= 1;
47585 }
47586         return ret_ref;
47587 }
47588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47589         LDKSignedRawInvoice arg_conv;
47590         arg_conv.inner = (void*)(arg & (~1));
47591         arg_conv.is_owned = false;
47592         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47593         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
47594         return ret_conv;
47595 }
47596
47597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47598         LDKSignedRawInvoice orig_conv;
47599         orig_conv.inner = (void*)(orig & (~1));
47600         orig_conv.is_owned = false;
47601         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47602         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
47603         int64_t ret_ref = 0;
47604         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47605         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47607         ret_ref = (uintptr_t)ret_var.inner;
47608         if (ret_var.is_owned) {
47609                 ret_ref |= 1;
47610         }
47611         return ret_ref;
47612 }
47613
47614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47615         LDKRawInvoice this_obj_conv;
47616         this_obj_conv.inner = (void*)(this_obj & (~1));
47617         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47619         RawInvoice_free(this_obj_conv);
47620 }
47621
47622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
47623         LDKRawInvoice this_ptr_conv;
47624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47625         this_ptr_conv.is_owned = false;
47626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47627         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
47628         int64_t ret_ref = 0;
47629         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47630         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47632         ret_ref = (uintptr_t)ret_var.inner;
47633         if (ret_var.is_owned) {
47634                 ret_ref |= 1;
47635         }
47636         return ret_ref;
47637 }
47638
47639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47640         LDKRawInvoice this_ptr_conv;
47641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47642         this_ptr_conv.is_owned = false;
47643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47644         LDKRawDataPart val_conv;
47645         val_conv.inner = (void*)(val & (~1));
47646         val_conv.is_owned = (val & 1) || (val == 0);
47647         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47648         val_conv = RawDataPart_clone(&val_conv);
47649         RawInvoice_set_data(&this_ptr_conv, val_conv);
47650 }
47651
47652 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47653         LDKRawInvoice a_conv;
47654         a_conv.inner = (void*)(a & (~1));
47655         a_conv.is_owned = false;
47656         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47657         LDKRawInvoice b_conv;
47658         b_conv.inner = (void*)(b & (~1));
47659         b_conv.is_owned = false;
47660         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47661         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
47662         return ret_conv;
47663 }
47664
47665 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
47666         LDKRawInvoice ret_var = RawInvoice_clone(arg);
47667 int64_t ret_ref = 0;
47668 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47669 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47670 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47671 ret_ref = (uintptr_t)ret_var.inner;
47672 if (ret_var.is_owned) {
47673         ret_ref |= 1;
47674 }
47675         return ret_ref;
47676 }
47677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47678         LDKRawInvoice arg_conv;
47679         arg_conv.inner = (void*)(arg & (~1));
47680         arg_conv.is_owned = false;
47681         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47682         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
47683         return ret_conv;
47684 }
47685
47686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47687         LDKRawInvoice orig_conv;
47688         orig_conv.inner = (void*)(orig & (~1));
47689         orig_conv.is_owned = false;
47690         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47691         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
47692         int64_t ret_ref = 0;
47693         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47694         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47696         ret_ref = (uintptr_t)ret_var.inner;
47697         if (ret_var.is_owned) {
47698                 ret_ref |= 1;
47699         }
47700         return ret_ref;
47701 }
47702
47703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47704         LDKRawDataPart this_obj_conv;
47705         this_obj_conv.inner = (void*)(this_obj & (~1));
47706         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47708         RawDataPart_free(this_obj_conv);
47709 }
47710
47711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
47712         LDKRawDataPart this_ptr_conv;
47713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47714         this_ptr_conv.is_owned = false;
47715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47716         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
47717         int64_t ret_ref = 0;
47718         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47719         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47721         ret_ref = (uintptr_t)ret_var.inner;
47722         if (ret_var.is_owned) {
47723                 ret_ref |= 1;
47724         }
47725         return ret_ref;
47726 }
47727
47728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47729         LDKRawDataPart this_ptr_conv;
47730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47731         this_ptr_conv.is_owned = false;
47732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47733         LDKPositiveTimestamp val_conv;
47734         val_conv.inner = (void*)(val & (~1));
47735         val_conv.is_owned = (val & 1) || (val == 0);
47736         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47737         val_conv = PositiveTimestamp_clone(&val_conv);
47738         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
47739 }
47740
47741 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47742         LDKRawDataPart a_conv;
47743         a_conv.inner = (void*)(a & (~1));
47744         a_conv.is_owned = false;
47745         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47746         LDKRawDataPart b_conv;
47747         b_conv.inner = (void*)(b & (~1));
47748         b_conv.is_owned = false;
47749         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47750         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
47751         return ret_conv;
47752 }
47753
47754 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
47755         LDKRawDataPart ret_var = RawDataPart_clone(arg);
47756 int64_t ret_ref = 0;
47757 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47758 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47759 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47760 ret_ref = (uintptr_t)ret_var.inner;
47761 if (ret_var.is_owned) {
47762         ret_ref |= 1;
47763 }
47764         return ret_ref;
47765 }
47766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47767         LDKRawDataPart arg_conv;
47768         arg_conv.inner = (void*)(arg & (~1));
47769         arg_conv.is_owned = false;
47770         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47771         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
47772         return ret_conv;
47773 }
47774
47775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47776         LDKRawDataPart orig_conv;
47777         orig_conv.inner = (void*)(orig & (~1));
47778         orig_conv.is_owned = false;
47779         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47780         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
47781         int64_t ret_ref = 0;
47782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47785         ret_ref = (uintptr_t)ret_var.inner;
47786         if (ret_var.is_owned) {
47787                 ret_ref |= 1;
47788         }
47789         return ret_ref;
47790 }
47791
47792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47793         LDKPositiveTimestamp this_obj_conv;
47794         this_obj_conv.inner = (void*)(this_obj & (~1));
47795         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47797         PositiveTimestamp_free(this_obj_conv);
47798 }
47799
47800 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47801         LDKPositiveTimestamp a_conv;
47802         a_conv.inner = (void*)(a & (~1));
47803         a_conv.is_owned = false;
47804         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47805         LDKPositiveTimestamp b_conv;
47806         b_conv.inner = (void*)(b & (~1));
47807         b_conv.is_owned = false;
47808         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47809         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
47810         return ret_conv;
47811 }
47812
47813 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
47814         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
47815 int64_t ret_ref = 0;
47816 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47817 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47818 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47819 ret_ref = (uintptr_t)ret_var.inner;
47820 if (ret_var.is_owned) {
47821         ret_ref |= 1;
47822 }
47823         return ret_ref;
47824 }
47825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47826         LDKPositiveTimestamp arg_conv;
47827         arg_conv.inner = (void*)(arg & (~1));
47828         arg_conv.is_owned = false;
47829         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47830         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
47831         return ret_conv;
47832 }
47833
47834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47835         LDKPositiveTimestamp orig_conv;
47836         orig_conv.inner = (void*)(orig & (~1));
47837         orig_conv.is_owned = false;
47838         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47839         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
47840         int64_t ret_ref = 0;
47841         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47842         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47844         ret_ref = (uintptr_t)ret_var.inner;
47845         if (ret_var.is_owned) {
47846                 ret_ref |= 1;
47847         }
47848         return ret_ref;
47849 }
47850
47851 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47852         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
47853         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
47854         return ret_conv;
47855 }
47856
47857 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
47858         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
47859         return ret_conv;
47860 }
47861
47862 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
47863         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
47864         return ret_conv;
47865 }
47866
47867 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
47868         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
47869         return ret_conv;
47870 }
47871
47872 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
47873         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
47874         return ret_conv;
47875 }
47876
47877 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47878         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
47879         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
47880         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
47881         return ret_conv;
47882 }
47883
47884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
47885         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
47886         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
47887         return ret_conv;
47888 }
47889
47890 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47891         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
47892         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
47893         return ret_conv;
47894 }
47895
47896 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
47897         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
47898         return ret_conv;
47899 }
47900
47901 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
47902         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
47903         return ret_conv;
47904 }
47905
47906 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
47907         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
47908         return ret_conv;
47909 }
47910
47911 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
47912         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
47913         return ret_conv;
47914 }
47915
47916 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
47917         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
47918         return ret_conv;
47919 }
47920
47921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
47922         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
47923         int64_t ret_conv = Currency_hash(o_conv);
47924         return ret_conv;
47925 }
47926
47927 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47928         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
47929         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
47930         jboolean ret_conv = Currency_eq(a_conv, b_conv);
47931         return ret_conv;
47932 }
47933
47934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47935         LDKSha256 this_obj_conv;
47936         this_obj_conv.inner = (void*)(this_obj & (~1));
47937         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47939         Sha256_free(this_obj_conv);
47940 }
47941
47942 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
47943         LDKSha256 ret_var = Sha256_clone(arg);
47944 int64_t ret_ref = 0;
47945 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47946 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47947 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47948 ret_ref = (uintptr_t)ret_var.inner;
47949 if (ret_var.is_owned) {
47950         ret_ref |= 1;
47951 }
47952         return ret_ref;
47953 }
47954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47955         LDKSha256 arg_conv;
47956         arg_conv.inner = (void*)(arg & (~1));
47957         arg_conv.is_owned = false;
47958         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47959         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
47960         return ret_conv;
47961 }
47962
47963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47964         LDKSha256 orig_conv;
47965         orig_conv.inner = (void*)(orig & (~1));
47966         orig_conv.is_owned = false;
47967         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47968         LDKSha256 ret_var = Sha256_clone(&orig_conv);
47969         int64_t ret_ref = 0;
47970         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47971         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47972         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47973         ret_ref = (uintptr_t)ret_var.inner;
47974         if (ret_var.is_owned) {
47975                 ret_ref |= 1;
47976         }
47977         return ret_ref;
47978 }
47979
47980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
47981         LDKSha256 o_conv;
47982         o_conv.inner = (void*)(o & (~1));
47983         o_conv.is_owned = false;
47984         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47985         int64_t ret_conv = Sha256_hash(&o_conv);
47986         return ret_conv;
47987 }
47988
47989 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47990         LDKSha256 a_conv;
47991         a_conv.inner = (void*)(a & (~1));
47992         a_conv.is_owned = false;
47993         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47994         LDKSha256 b_conv;
47995         b_conv.inner = (void*)(b & (~1));
47996         b_conv.is_owned = false;
47997         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47998         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
47999         return ret_conv;
48000 }
48001
48002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48003         LDKDescription this_obj_conv;
48004         this_obj_conv.inner = (void*)(this_obj & (~1));
48005         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48007         Description_free(this_obj_conv);
48008 }
48009
48010 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
48011         LDKDescription ret_var = Description_clone(arg);
48012 int64_t ret_ref = 0;
48013 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48014 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48015 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48016 ret_ref = (uintptr_t)ret_var.inner;
48017 if (ret_var.is_owned) {
48018         ret_ref |= 1;
48019 }
48020         return ret_ref;
48021 }
48022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48023         LDKDescription arg_conv;
48024         arg_conv.inner = (void*)(arg & (~1));
48025         arg_conv.is_owned = false;
48026         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48027         int64_t ret_conv = Description_clone_ptr(&arg_conv);
48028         return ret_conv;
48029 }
48030
48031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48032         LDKDescription orig_conv;
48033         orig_conv.inner = (void*)(orig & (~1));
48034         orig_conv.is_owned = false;
48035         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48036         LDKDescription ret_var = Description_clone(&orig_conv);
48037         int64_t ret_ref = 0;
48038         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48039         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48041         ret_ref = (uintptr_t)ret_var.inner;
48042         if (ret_var.is_owned) {
48043                 ret_ref |= 1;
48044         }
48045         return ret_ref;
48046 }
48047
48048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
48049         LDKDescription o_conv;
48050         o_conv.inner = (void*)(o & (~1));
48051         o_conv.is_owned = false;
48052         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48053         int64_t ret_conv = Description_hash(&o_conv);
48054         return ret_conv;
48055 }
48056
48057 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48058         LDKDescription a_conv;
48059         a_conv.inner = (void*)(a & (~1));
48060         a_conv.is_owned = false;
48061         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48062         LDKDescription b_conv;
48063         b_conv.inner = (void*)(b & (~1));
48064         b_conv.is_owned = false;
48065         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48066         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
48067         return ret_conv;
48068 }
48069
48070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48071         LDKPayeePubKey this_obj_conv;
48072         this_obj_conv.inner = (void*)(this_obj & (~1));
48073         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48075         PayeePubKey_free(this_obj_conv);
48076 }
48077
48078 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
48079         LDKPayeePubKey this_ptr_conv;
48080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
48081         this_ptr_conv.is_owned = false;
48082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48083         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
48084         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
48085         return ret_arr;
48086 }
48087
48088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
48089         LDKPayeePubKey this_ptr_conv;
48090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
48091         this_ptr_conv.is_owned = false;
48092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48093         LDKPublicKey val_ref;
48094         CHECK((*env)->GetArrayLength(env, val) == 33);
48095         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
48096         PayeePubKey_set_a(&this_ptr_conv, val_ref);
48097 }
48098
48099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
48100         LDKPublicKey a_arg_ref;
48101         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
48102         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
48103         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
48104         int64_t ret_ref = 0;
48105         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48106         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48108         ret_ref = (uintptr_t)ret_var.inner;
48109         if (ret_var.is_owned) {
48110                 ret_ref |= 1;
48111         }
48112         return ret_ref;
48113 }
48114
48115 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
48116         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
48117 int64_t ret_ref = 0;
48118 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48119 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48120 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48121 ret_ref = (uintptr_t)ret_var.inner;
48122 if (ret_var.is_owned) {
48123         ret_ref |= 1;
48124 }
48125         return ret_ref;
48126 }
48127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48128         LDKPayeePubKey arg_conv;
48129         arg_conv.inner = (void*)(arg & (~1));
48130         arg_conv.is_owned = false;
48131         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48132         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
48133         return ret_conv;
48134 }
48135
48136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48137         LDKPayeePubKey orig_conv;
48138         orig_conv.inner = (void*)(orig & (~1));
48139         orig_conv.is_owned = false;
48140         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48141         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
48142         int64_t ret_ref = 0;
48143         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48144         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48146         ret_ref = (uintptr_t)ret_var.inner;
48147         if (ret_var.is_owned) {
48148                 ret_ref |= 1;
48149         }
48150         return ret_ref;
48151 }
48152
48153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
48154         LDKPayeePubKey o_conv;
48155         o_conv.inner = (void*)(o & (~1));
48156         o_conv.is_owned = false;
48157         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48158         int64_t ret_conv = PayeePubKey_hash(&o_conv);
48159         return ret_conv;
48160 }
48161
48162 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48163         LDKPayeePubKey a_conv;
48164         a_conv.inner = (void*)(a & (~1));
48165         a_conv.is_owned = false;
48166         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48167         LDKPayeePubKey b_conv;
48168         b_conv.inner = (void*)(b & (~1));
48169         b_conv.is_owned = false;
48170         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48171         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
48172         return ret_conv;
48173 }
48174
48175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48176         LDKExpiryTime this_obj_conv;
48177         this_obj_conv.inner = (void*)(this_obj & (~1));
48178         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48180         ExpiryTime_free(this_obj_conv);
48181 }
48182
48183 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
48184         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
48185 int64_t ret_ref = 0;
48186 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48187 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48188 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48189 ret_ref = (uintptr_t)ret_var.inner;
48190 if (ret_var.is_owned) {
48191         ret_ref |= 1;
48192 }
48193         return ret_ref;
48194 }
48195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48196         LDKExpiryTime arg_conv;
48197         arg_conv.inner = (void*)(arg & (~1));
48198         arg_conv.is_owned = false;
48199         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48200         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
48201         return ret_conv;
48202 }
48203
48204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48205         LDKExpiryTime orig_conv;
48206         orig_conv.inner = (void*)(orig & (~1));
48207         orig_conv.is_owned = false;
48208         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48209         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
48210         int64_t ret_ref = 0;
48211         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48212         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48214         ret_ref = (uintptr_t)ret_var.inner;
48215         if (ret_var.is_owned) {
48216                 ret_ref |= 1;
48217         }
48218         return ret_ref;
48219 }
48220
48221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
48222         LDKExpiryTime o_conv;
48223         o_conv.inner = (void*)(o & (~1));
48224         o_conv.is_owned = false;
48225         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48226         int64_t ret_conv = ExpiryTime_hash(&o_conv);
48227         return ret_conv;
48228 }
48229
48230 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48231         LDKExpiryTime a_conv;
48232         a_conv.inner = (void*)(a & (~1));
48233         a_conv.is_owned = false;
48234         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48235         LDKExpiryTime b_conv;
48236         b_conv.inner = (void*)(b & (~1));
48237         b_conv.is_owned = false;
48238         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48239         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
48240         return ret_conv;
48241 }
48242
48243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48244         LDKMinFinalCltvExpiry this_obj_conv;
48245         this_obj_conv.inner = (void*)(this_obj & (~1));
48246         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48248         MinFinalCltvExpiry_free(this_obj_conv);
48249 }
48250
48251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
48252         LDKMinFinalCltvExpiry this_ptr_conv;
48253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
48254         this_ptr_conv.is_owned = false;
48255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48256         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
48257         return ret_conv;
48258 }
48259
48260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48261         LDKMinFinalCltvExpiry this_ptr_conv;
48262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
48263         this_ptr_conv.is_owned = false;
48264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48265         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
48266 }
48267
48268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
48269         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
48270         int64_t ret_ref = 0;
48271         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48272         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48273         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48274         ret_ref = (uintptr_t)ret_var.inner;
48275         if (ret_var.is_owned) {
48276                 ret_ref |= 1;
48277         }
48278         return ret_ref;
48279 }
48280
48281 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
48282         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
48283 int64_t ret_ref = 0;
48284 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48285 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48286 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48287 ret_ref = (uintptr_t)ret_var.inner;
48288 if (ret_var.is_owned) {
48289         ret_ref |= 1;
48290 }
48291         return ret_ref;
48292 }
48293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48294         LDKMinFinalCltvExpiry arg_conv;
48295         arg_conv.inner = (void*)(arg & (~1));
48296         arg_conv.is_owned = false;
48297         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48298         int64_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
48299         return ret_conv;
48300 }
48301
48302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48303         LDKMinFinalCltvExpiry orig_conv;
48304         orig_conv.inner = (void*)(orig & (~1));
48305         orig_conv.is_owned = false;
48306         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48307         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
48308         int64_t ret_ref = 0;
48309         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48310         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48312         ret_ref = (uintptr_t)ret_var.inner;
48313         if (ret_var.is_owned) {
48314                 ret_ref |= 1;
48315         }
48316         return ret_ref;
48317 }
48318
48319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
48320         LDKMinFinalCltvExpiry o_conv;
48321         o_conv.inner = (void*)(o & (~1));
48322         o_conv.is_owned = false;
48323         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48324         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
48325         return ret_conv;
48326 }
48327
48328 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48329         LDKMinFinalCltvExpiry a_conv;
48330         a_conv.inner = (void*)(a & (~1));
48331         a_conv.is_owned = false;
48332         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48333         LDKMinFinalCltvExpiry b_conv;
48334         b_conv.inner = (void*)(b & (~1));
48335         b_conv.is_owned = false;
48336         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48337         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
48338         return ret_conv;
48339 }
48340
48341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48342         if ((this_ptr & 1) != 0) return;
48343         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
48344         CHECK_ACCESS(this_ptr_ptr);
48345         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
48346         FREE((void*)this_ptr);
48347         Fallback_free(this_ptr_conv);
48348 }
48349
48350 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
48351         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48352         *ret_copy = Fallback_clone(arg);
48353 int64_t ret_ref = (uintptr_t)ret_copy;
48354         return ret_ref;
48355 }
48356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48357         LDKFallback* arg_conv = (LDKFallback*)arg;
48358         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
48359         return ret_conv;
48360 }
48361
48362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48363         LDKFallback* orig_conv = (LDKFallback*)orig;
48364         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48365         *ret_copy = Fallback_clone(orig_conv);
48366         int64_t ret_ref = (uintptr_t)ret_copy;
48367         return ret_ref;
48368 }
48369
48370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
48371         
48372         LDKCVec_u8Z program_ref;
48373         program_ref.datalen = (*env)->GetArrayLength(env, program);
48374         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
48375         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
48376         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48377         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
48378         int64_t ret_ref = (uintptr_t)ret_copy;
48379         return ret_ref;
48380 }
48381
48382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
48383         LDKTwentyBytes a_ref;
48384         CHECK((*env)->GetArrayLength(env, a) == 20);
48385         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
48386         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48387         *ret_copy = Fallback_pub_key_hash(a_ref);
48388         int64_t ret_ref = (uintptr_t)ret_copy;
48389         return ret_ref;
48390 }
48391
48392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
48393         LDKTwentyBytes a_ref;
48394         CHECK((*env)->GetArrayLength(env, a) == 20);
48395         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
48396         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48397         *ret_copy = Fallback_script_hash(a_ref);
48398         int64_t ret_ref = (uintptr_t)ret_copy;
48399         return ret_ref;
48400 }
48401
48402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
48403         LDKFallback* o_conv = (LDKFallback*)o;
48404         int64_t ret_conv = Fallback_hash(o_conv);
48405         return ret_conv;
48406 }
48407
48408 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48409         LDKFallback* a_conv = (LDKFallback*)a;
48410         LDKFallback* b_conv = (LDKFallback*)b;
48411         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
48412         return ret_conv;
48413 }
48414
48415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48416         LDKInvoiceSignature this_obj_conv;
48417         this_obj_conv.inner = (void*)(this_obj & (~1));
48418         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48420         InvoiceSignature_free(this_obj_conv);
48421 }
48422
48423 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
48424         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
48425 int64_t ret_ref = 0;
48426 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48427 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48428 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48429 ret_ref = (uintptr_t)ret_var.inner;
48430 if (ret_var.is_owned) {
48431         ret_ref |= 1;
48432 }
48433         return ret_ref;
48434 }
48435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48436         LDKInvoiceSignature arg_conv;
48437         arg_conv.inner = (void*)(arg & (~1));
48438         arg_conv.is_owned = false;
48439         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48440         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
48441         return ret_conv;
48442 }
48443
48444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48445         LDKInvoiceSignature orig_conv;
48446         orig_conv.inner = (void*)(orig & (~1));
48447         orig_conv.is_owned = false;
48448         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48449         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
48450         int64_t ret_ref = 0;
48451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48454         ret_ref = (uintptr_t)ret_var.inner;
48455         if (ret_var.is_owned) {
48456                 ret_ref |= 1;
48457         }
48458         return ret_ref;
48459 }
48460
48461 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48462         LDKInvoiceSignature a_conv;
48463         a_conv.inner = (void*)(a & (~1));
48464         a_conv.is_owned = false;
48465         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48466         LDKInvoiceSignature b_conv;
48467         b_conv.inner = (void*)(b & (~1));
48468         b_conv.is_owned = false;
48469         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48470         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
48471         return ret_conv;
48472 }
48473
48474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48475         LDKPrivateRoute this_obj_conv;
48476         this_obj_conv.inner = (void*)(this_obj & (~1));
48477         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48479         PrivateRoute_free(this_obj_conv);
48480 }
48481
48482 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
48483         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
48484 int64_t ret_ref = 0;
48485 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48486 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48487 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48488 ret_ref = (uintptr_t)ret_var.inner;
48489 if (ret_var.is_owned) {
48490         ret_ref |= 1;
48491 }
48492         return ret_ref;
48493 }
48494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48495         LDKPrivateRoute arg_conv;
48496         arg_conv.inner = (void*)(arg & (~1));
48497         arg_conv.is_owned = false;
48498         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48499         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
48500         return ret_conv;
48501 }
48502
48503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48504         LDKPrivateRoute orig_conv;
48505         orig_conv.inner = (void*)(orig & (~1));
48506         orig_conv.is_owned = false;
48507         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48508         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
48509         int64_t ret_ref = 0;
48510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48513         ret_ref = (uintptr_t)ret_var.inner;
48514         if (ret_var.is_owned) {
48515                 ret_ref |= 1;
48516         }
48517         return ret_ref;
48518 }
48519
48520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
48521         LDKPrivateRoute o_conv;
48522         o_conv.inner = (void*)(o & (~1));
48523         o_conv.is_owned = false;
48524         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48525         int64_t ret_conv = PrivateRoute_hash(&o_conv);
48526         return ret_conv;
48527 }
48528
48529 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48530         LDKPrivateRoute a_conv;
48531         a_conv.inner = (void*)(a & (~1));
48532         a_conv.is_owned = false;
48533         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48534         LDKPrivateRoute b_conv;
48535         b_conv.inner = (void*)(b & (~1));
48536         b_conv.is_owned = false;
48537         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48538         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
48539         return ret_conv;
48540 }
48541
48542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
48543         LDKSignedRawInvoice this_arg_conv;
48544         this_arg_conv.inner = (void*)(this_arg & (~1));
48545         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
48546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48547         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
48548         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
48549         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
48550         return ((int64_t)ret_conv);
48551 }
48552
48553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
48554         LDKSignedRawInvoice this_arg_conv;
48555         this_arg_conv.inner = (void*)(this_arg & (~1));
48556         this_arg_conv.is_owned = false;
48557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48558         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
48559         int64_t ret_ref = 0;
48560         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48561         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48562         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48563         ret_ref = (uintptr_t)ret_var.inner;
48564         if (ret_var.is_owned) {
48565                 ret_ref |= 1;
48566         }
48567         return ret_ref;
48568 }
48569
48570 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48571         LDKSignedRawInvoice this_arg_conv;
48572         this_arg_conv.inner = (void*)(this_arg & (~1));
48573         this_arg_conv.is_owned = false;
48574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48575         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48576         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
48577         return ret_arr;
48578 }
48579
48580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
48581         LDKSignedRawInvoice this_arg_conv;
48582         this_arg_conv.inner = (void*)(this_arg & (~1));
48583         this_arg_conv.is_owned = false;
48584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48585         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
48586         int64_t ret_ref = 0;
48587         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48588         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48590         ret_ref = (uintptr_t)ret_var.inner;
48591         if (ret_var.is_owned) {
48592                 ret_ref |= 1;
48593         }
48594         return ret_ref;
48595 }
48596
48597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
48598         LDKSignedRawInvoice this_arg_conv;
48599         this_arg_conv.inner = (void*)(this_arg & (~1));
48600         this_arg_conv.is_owned = false;
48601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48602         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
48603         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
48604         return (int64_t)ret_conv;
48605 }
48606
48607 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
48608         LDKSignedRawInvoice this_arg_conv;
48609         this_arg_conv.inner = (void*)(this_arg & (~1));
48610         this_arg_conv.is_owned = false;
48611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48612         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
48613         return ret_conv;
48614 }
48615
48616 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48617         LDKRawInvoice this_arg_conv;
48618         this_arg_conv.inner = (void*)(this_arg & (~1));
48619         this_arg_conv.is_owned = false;
48620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48621         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48622         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
48623         return ret_arr;
48624 }
48625
48626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48627         LDKRawInvoice this_arg_conv;
48628         this_arg_conv.inner = (void*)(this_arg & (~1));
48629         this_arg_conv.is_owned = false;
48630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48631         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
48632         int64_t ret_ref = 0;
48633         if ((uintptr_t)ret_var.inner > 4096) {
48634                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48635                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48637                 ret_ref = (uintptr_t)ret_var.inner;
48638                 if (ret_var.is_owned) {
48639                         ret_ref |= 1;
48640                 }
48641         }
48642         return ret_ref;
48643 }
48644
48645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
48646         LDKRawInvoice this_arg_conv;
48647         this_arg_conv.inner = (void*)(this_arg & (~1));
48648         this_arg_conv.is_owned = false;
48649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48650         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
48651         int64_t ret_ref = 0;
48652         if ((uintptr_t)ret_var.inner > 4096) {
48653                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48654                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48656                 ret_ref = (uintptr_t)ret_var.inner;
48657                 if (ret_var.is_owned) {
48658                         ret_ref |= 1;
48659                 }
48660         }
48661         return ret_ref;
48662 }
48663
48664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
48665         LDKRawInvoice this_arg_conv;
48666         this_arg_conv.inner = (void*)(this_arg & (~1));
48667         this_arg_conv.is_owned = false;
48668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48669         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
48670         int64_t ret_ref = 0;
48671         if ((uintptr_t)ret_var.inner > 4096) {
48672                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48673                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48675                 ret_ref = (uintptr_t)ret_var.inner;
48676                 if (ret_var.is_owned) {
48677                         ret_ref |= 1;
48678                 }
48679         }
48680         return ret_ref;
48681 }
48682
48683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48684         LDKRawInvoice this_arg_conv;
48685         this_arg_conv.inner = (void*)(this_arg & (~1));
48686         this_arg_conv.is_owned = false;
48687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48688         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
48689         int64_t ret_ref = 0;
48690         if ((uintptr_t)ret_var.inner > 4096) {
48691                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48692                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48694                 ret_ref = (uintptr_t)ret_var.inner;
48695                 if (ret_var.is_owned) {
48696                         ret_ref |= 1;
48697                 }
48698         }
48699         return ret_ref;
48700 }
48701
48702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
48703         LDKRawInvoice this_arg_conv;
48704         this_arg_conv.inner = (void*)(this_arg & (~1));
48705         this_arg_conv.is_owned = false;
48706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48707         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
48708         int64_t ret_ref = 0;
48709         if ((uintptr_t)ret_var.inner > 4096) {
48710                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48711                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48713                 ret_ref = (uintptr_t)ret_var.inner;
48714                 if (ret_var.is_owned) {
48715                         ret_ref |= 1;
48716                 }
48717         }
48718         return ret_ref;
48719 }
48720
48721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
48722         LDKRawInvoice this_arg_conv;
48723         this_arg_conv.inner = (void*)(this_arg & (~1));
48724         this_arg_conv.is_owned = false;
48725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48726         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
48727         int64_t ret_ref = 0;
48728         if ((uintptr_t)ret_var.inner > 4096) {
48729                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48730                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48732                 ret_ref = (uintptr_t)ret_var.inner;
48733                 if (ret_var.is_owned) {
48734                         ret_ref |= 1;
48735                 }
48736         }
48737         return ret_ref;
48738 }
48739
48740 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
48741         LDKRawInvoice this_arg_conv;
48742         this_arg_conv.inner = (void*)(this_arg & (~1));
48743         this_arg_conv.is_owned = false;
48744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48745         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48746         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
48747         return ret_arr;
48748 }
48749
48750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
48751         LDKRawInvoice this_arg_conv;
48752         this_arg_conv.inner = (void*)(this_arg & (~1));
48753         this_arg_conv.is_owned = false;
48754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48755         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
48756         int64_t ret_ref = 0;
48757         if ((uintptr_t)ret_var.inner > 4096) {
48758                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48759                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48761                 ret_ref = (uintptr_t)ret_var.inner;
48762                 if (ret_var.is_owned) {
48763                         ret_ref |= 1;
48764                 }
48765         }
48766         return ret_ref;
48767 }
48768
48769 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
48770         LDKRawInvoice this_arg_conv;
48771         this_arg_conv.inner = (void*)(this_arg & (~1));
48772         this_arg_conv.is_owned = false;
48773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48774         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
48775         int64_tArray ret_arr = NULL;
48776         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
48777         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
48778         for (size_t o = 0; o < ret_var.datalen; o++) {
48779                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
48780                 int64_t ret_conv_14_ref = 0;
48781                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48782                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48783                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
48784                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
48785                 if (ret_conv_14_var.is_owned) {
48786                         ret_conv_14_ref |= 1;
48787                 }
48788                 ret_arr_ptr[o] = ret_conv_14_ref;
48789         }
48790         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
48791         FREE(ret_var.data);
48792         return ret_arr;
48793 }
48794
48795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
48796         LDKRawInvoice this_arg_conv;
48797         this_arg_conv.inner = (void*)(this_arg & (~1));
48798         this_arg_conv.is_owned = false;
48799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48800         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
48801         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
48802         int64_t ret_ref = (uintptr_t)ret_copy;
48803         return ret_ref;
48804 }
48805
48806 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
48807         LDKRawInvoice this_arg_conv;
48808         this_arg_conv.inner = (void*)(this_arg & (~1));
48809         this_arg_conv.is_owned = false;
48810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48811         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
48812         return ret_conv;
48813 }
48814
48815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
48816         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
48817         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
48818         return (int64_t)ret_conv;
48819 }
48820
48821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
48822         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
48823         *ret_conv = PositiveTimestamp_from_system_time(time);
48824         return (int64_t)ret_conv;
48825 }
48826
48827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
48828         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
48829         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
48830         return (int64_t)ret_conv;
48831 }
48832
48833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
48834         LDKPositiveTimestamp this_arg_conv;
48835         this_arg_conv.inner = (void*)(this_arg & (~1));
48836         this_arg_conv.is_owned = false;
48837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48838         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
48839         return ret_conv;
48840 }
48841
48842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
48843         LDKPositiveTimestamp this_arg_conv;
48844         this_arg_conv.inner = (void*)(this_arg & (~1));
48845         this_arg_conv.is_owned = false;
48846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48847         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
48848         return ret_conv;
48849 }
48850
48851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
48852         LDKPositiveTimestamp this_arg_conv;
48853         this_arg_conv.inner = (void*)(this_arg & (~1));
48854         this_arg_conv.is_owned = false;
48855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48856         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
48857         return ret_conv;
48858 }
48859
48860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
48861         LDKInvoice this_arg_conv;
48862         this_arg_conv.inner = (void*)(this_arg & (~1));
48863         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
48864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48865         this_arg_conv = Invoice_clone(&this_arg_conv);
48866         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
48867         int64_t ret_ref = 0;
48868         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48869         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48871         ret_ref = (uintptr_t)ret_var.inner;
48872         if (ret_var.is_owned) {
48873                 ret_ref |= 1;
48874         }
48875         return ret_ref;
48876 }
48877
48878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
48879         LDKInvoice this_arg_conv;
48880         this_arg_conv.inner = (void*)(this_arg & (~1));
48881         this_arg_conv.is_owned = false;
48882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48883         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
48884         *ret_conv = Invoice_check_signature(&this_arg_conv);
48885         return (int64_t)ret_conv;
48886 }
48887
48888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
48889         LDKSignedRawInvoice signed_invoice_conv;
48890         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
48891         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
48892         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
48893         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
48894         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
48895         *ret_conv = Invoice_from_signed(signed_invoice_conv);
48896         return (int64_t)ret_conv;
48897 }
48898
48899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
48900         LDKInvoice this_arg_conv;
48901         this_arg_conv.inner = (void*)(this_arg & (~1));
48902         this_arg_conv.is_owned = false;
48903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48904         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
48905         return ret_conv;
48906 }
48907
48908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
48909         LDKInvoice this_arg_conv;
48910         this_arg_conv.inner = (void*)(this_arg & (~1));
48911         this_arg_conv.is_owned = false;
48912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48913         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
48914         return ret_conv;
48915 }
48916
48917 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48918         LDKInvoice this_arg_conv;
48919         this_arg_conv.inner = (void*)(this_arg & (~1));
48920         this_arg_conv.is_owned = false;
48921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48922         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48923         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
48924         return ret_arr;
48925 }
48926
48927 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
48928         LDKInvoice this_arg_conv;
48929         this_arg_conv.inner = (void*)(this_arg & (~1));
48930         this_arg_conv.is_owned = false;
48931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48932         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
48933         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
48934         return ret_arr;
48935 }
48936
48937 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
48938         LDKInvoice this_arg_conv;
48939         this_arg_conv.inner = (void*)(this_arg & (~1));
48940         this_arg_conv.is_owned = false;
48941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48942         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48943         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
48944         return ret_arr;
48945 }
48946
48947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
48948         LDKInvoice this_arg_conv;
48949         this_arg_conv.inner = (void*)(this_arg & (~1));
48950         this_arg_conv.is_owned = false;
48951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48952         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
48953         int64_t ret_ref = 0;
48954         if ((uintptr_t)ret_var.inner > 4096) {
48955                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48956                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48958                 ret_ref = (uintptr_t)ret_var.inner;
48959                 if (ret_var.is_owned) {
48960                         ret_ref |= 1;
48961                 }
48962         }
48963         return ret_ref;
48964 }
48965
48966 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
48967         LDKInvoice this_arg_conv;
48968         this_arg_conv.inner = (void*)(this_arg & (~1));
48969         this_arg_conv.is_owned = false;
48970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48971         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
48972         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
48973         return ret_arr;
48974 }
48975
48976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
48977         LDKInvoice this_arg_conv;
48978         this_arg_conv.inner = (void*)(this_arg & (~1));
48979         this_arg_conv.is_owned = false;
48980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48981         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
48982         return ret_conv;
48983 }
48984
48985 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
48986         LDKInvoice this_arg_conv;
48987         this_arg_conv.inner = (void*)(this_arg & (~1));
48988         this_arg_conv.is_owned = false;
48989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48990         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
48991         return ret_conv;
48992 }
48993
48994 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
48995         LDKInvoice this_arg_conv;
48996         this_arg_conv.inner = (void*)(this_arg & (~1));
48997         this_arg_conv.is_owned = false;
48998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48999         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
49000         return ret_conv;
49001 }
49002
49003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
49004         LDKInvoice this_arg_conv;
49005         this_arg_conv.inner = (void*)(this_arg & (~1));
49006         this_arg_conv.is_owned = false;
49007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49008         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
49009         return ret_conv;
49010 }
49011
49012 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
49013         LDKInvoice this_arg_conv;
49014         this_arg_conv.inner = (void*)(this_arg & (~1));
49015         this_arg_conv.is_owned = false;
49016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49017         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
49018         int64_tArray ret_arr = NULL;
49019         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49020         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49021         for (size_t o = 0; o < ret_var.datalen; o++) {
49022                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
49023                 int64_t ret_conv_14_ref = 0;
49024                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49025                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49026                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
49027                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
49028                 if (ret_conv_14_var.is_owned) {
49029                         ret_conv_14_ref |= 1;
49030                 }
49031                 ret_arr_ptr[o] = ret_conv_14_ref;
49032         }
49033         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49034         FREE(ret_var.data);
49035         return ret_arr;
49036 }
49037
49038 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
49039         LDKInvoice this_arg_conv;
49040         this_arg_conv.inner = (void*)(this_arg & (~1));
49041         this_arg_conv.is_owned = false;
49042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49043         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
49044         int64_tArray ret_arr = NULL;
49045         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49046         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49047         for (size_t l = 0; l < ret_var.datalen; l++) {
49048                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
49049                 int64_t ret_conv_11_ref = 0;
49050                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49051                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49052                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
49053                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
49054                 if (ret_conv_11_var.is_owned) {
49055                         ret_conv_11_ref |= 1;
49056                 }
49057                 ret_arr_ptr[l] = ret_conv_11_ref;
49058         }
49059         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49060         FREE(ret_var.data);
49061         return ret_arr;
49062 }
49063
49064 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
49065         LDKInvoice this_arg_conv;
49066         this_arg_conv.inner = (void*)(this_arg & (~1));
49067         this_arg_conv.is_owned = false;
49068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49069         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
49070         return ret_conv;
49071 }
49072
49073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
49074         LDKInvoice this_arg_conv;
49075         this_arg_conv.inner = (void*)(this_arg & (~1));
49076         this_arg_conv.is_owned = false;
49077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49078         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
49079         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
49080         int64_t ret_ref = (uintptr_t)ret_copy;
49081         return ret_ref;
49082 }
49083
49084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
49085         LDKStr description_conv = java_to_owned_str(env, description);
49086         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
49087         *ret_conv = Description_new(description_conv);
49088         return (int64_t)ret_conv;
49089 }
49090
49091 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
49092         LDKDescription this_arg_conv;
49093         this_arg_conv.inner = (void*)(this_arg & (~1));
49094         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
49095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49096         this_arg_conv = Description_clone(&this_arg_conv);
49097         LDKStr ret_str = Description_into_inner(this_arg_conv);
49098         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49099         Str_free(ret_str);
49100         return ret_conv;
49101 }
49102
49103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
49104         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
49105         int64_t ret_ref = 0;
49106         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49107         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49109         ret_ref = (uintptr_t)ret_var.inner;
49110         if (ret_var.is_owned) {
49111                 ret_ref |= 1;
49112         }
49113         return ret_ref;
49114 }
49115
49116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
49117         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
49118         int64_t ret_ref = 0;
49119         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49120         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49122         ret_ref = (uintptr_t)ret_var.inner;
49123         if (ret_var.is_owned) {
49124                 ret_ref |= 1;
49125         }
49126         return ret_ref;
49127 }
49128
49129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
49130         LDKExpiryTime this_arg_conv;
49131         this_arg_conv.inner = (void*)(this_arg & (~1));
49132         this_arg_conv.is_owned = false;
49133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49134         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
49135         return ret_conv;
49136 }
49137
49138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
49139         LDKExpiryTime this_arg_conv;
49140         this_arg_conv.inner = (void*)(this_arg & (~1));
49141         this_arg_conv.is_owned = false;
49142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49143         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
49144         return ret_conv;
49145 }
49146
49147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
49148         LDKRouteHint hops_conv;
49149         hops_conv.inner = (void*)(hops & (~1));
49150         hops_conv.is_owned = (hops & 1) || (hops == 0);
49151         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
49152         hops_conv = RouteHint_clone(&hops_conv);
49153         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
49154         *ret_conv = PrivateRoute_new(hops_conv);
49155         return (int64_t)ret_conv;
49156 }
49157
49158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
49159         LDKPrivateRoute this_arg_conv;
49160         this_arg_conv.inner = (void*)(this_arg & (~1));
49161         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
49162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49163         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
49164         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
49165         int64_t ret_ref = 0;
49166         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49167         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49169         ret_ref = (uintptr_t)ret_var.inner;
49170         if (ret_var.is_owned) {
49171                 ret_ref |= 1;
49172         }
49173         return ret_ref;
49174 }
49175
49176 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49177         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
49178         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
49179         return ret_conv;
49180 }
49181
49182 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
49183         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
49184         return ret_conv;
49185 }
49186
49187 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
49188         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
49189         return ret_conv;
49190 }
49191
49192 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
49193         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
49194         return ret_conv;
49195 }
49196
49197 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
49198         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
49199         return ret_conv;
49200 }
49201
49202 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
49203         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
49204         return ret_conv;
49205 }
49206
49207 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49208         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
49209         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
49210         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
49211         return ret_conv;
49212 }
49213
49214 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49215         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
49216         LDKStr ret_str = CreationError_to_str(o_conv);
49217         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49218         Str_free(ret_str);
49219         return ret_conv;
49220 }
49221
49222 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49223         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
49224         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
49225         return ret_conv;
49226 }
49227
49228 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
49229         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
49230         return ret_conv;
49231 }
49232
49233 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
49234         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
49235         return ret_conv;
49236 }
49237
49238 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
49239         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
49240         return ret_conv;
49241 }
49242
49243 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
49244         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
49245         return ret_conv;
49246 }
49247
49248 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
49249         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
49250         return ret_conv;
49251 }
49252
49253 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
49254         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
49255         return ret_conv;
49256 }
49257
49258 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
49259         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
49260         return ret_conv;
49261 }
49262
49263 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
49264         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
49265         return ret_conv;
49266 }
49267
49268 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
49269         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
49270         return ret_conv;
49271 }
49272
49273 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
49274         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
49275         return ret_conv;
49276 }
49277
49278 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49279         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
49280         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
49281         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
49282         return ret_conv;
49283 }
49284
49285 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49286         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
49287         LDKStr ret_str = SemanticError_to_str(o_conv);
49288         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49289         Str_free(ret_str);
49290         return ret_conv;
49291 }
49292
49293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49294         if ((this_ptr & 1) != 0) return;
49295         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49296         CHECK_ACCESS(this_ptr_ptr);
49297         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
49298         FREE((void*)this_ptr);
49299         SignOrCreationError_free(this_ptr_conv);
49300 }
49301
49302 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
49303         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49304         *ret_copy = SignOrCreationError_clone(arg);
49305 int64_t ret_ref = (uintptr_t)ret_copy;
49306         return ret_ref;
49307 }
49308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49309         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
49310         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
49311         return ret_conv;
49312 }
49313
49314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49315         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
49316         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49317         *ret_copy = SignOrCreationError_clone(orig_conv);
49318         int64_t ret_ref = (uintptr_t)ret_copy;
49319         return ret_ref;
49320 }
49321
49322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
49323         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49324         *ret_copy = SignOrCreationError_sign_error();
49325         int64_t ret_ref = (uintptr_t)ret_copy;
49326         return ret_ref;
49327 }
49328
49329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
49330         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
49331         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49332         *ret_copy = SignOrCreationError_creation_error(a_conv);
49333         int64_t ret_ref = (uintptr_t)ret_copy;
49334         return ret_ref;
49335 }
49336
49337 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49338         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
49339         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
49340         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
49341         return ret_conv;
49342 }
49343
49344 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49345         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
49346         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
49347         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49348         Str_free(ret_str);
49349         return ret_conv;
49350 }
49351
49352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49353         LDKInvoicePayer this_obj_conv;
49354         this_obj_conv.inner = (void*)(this_obj & (~1));
49355         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
49356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49357         InvoicePayer_free(this_obj_conv);
49358 }
49359
49360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49361         if ((this_ptr & 1) != 0) return;
49362         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49363         CHECK_ACCESS(this_ptr_ptr);
49364         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
49365         FREE((void*)this_ptr);
49366         Payer_free(this_ptr_conv);
49367 }
49368
49369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49370         if ((this_ptr & 1) != 0) return;
49371         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49372         CHECK_ACCESS(this_ptr_ptr);
49373         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
49374         FREE((void*)this_ptr);
49375         Router_free(this_ptr_conv);
49376 }
49377
49378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Retry_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49379         if ((this_ptr & 1) != 0) return;
49380         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49381         CHECK_ACCESS(this_ptr_ptr);
49382         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
49383         FREE((void*)this_ptr);
49384         Retry_free(this_ptr_conv);
49385 }
49386
49387 static inline uintptr_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
49388         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49389         *ret_copy = Retry_clone(arg);
49390 int64_t ret_ref = (uintptr_t)ret_copy;
49391         return ret_ref;
49392 }
49393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49394         LDKRetry* arg_conv = (LDKRetry*)arg;
49395         int64_t ret_conv = Retry_clone_ptr(arg_conv);
49396         return ret_conv;
49397 }
49398
49399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49400         LDKRetry* orig_conv = (LDKRetry*)orig;
49401         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49402         *ret_copy = Retry_clone(orig_conv);
49403         int64_t ret_ref = (uintptr_t)ret_copy;
49404         return ret_ref;
49405 }
49406
49407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1attempts(JNIEnv *env, jclass clz, int64_t a) {
49408         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49409         *ret_copy = Retry_attempts(a);
49410         int64_t ret_ref = (uintptr_t)ret_copy;
49411         return ret_ref;
49412 }
49413
49414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1timeout(JNIEnv *env, jclass clz, int64_t a) {
49415         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49416         *ret_copy = Retry_timeout(a);
49417         int64_t ret_ref = (uintptr_t)ret_copy;
49418         return ret_ref;
49419 }
49420
49421 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Retry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49422         LDKRetry* a_conv = (LDKRetry*)a;
49423         LDKRetry* b_conv = (LDKRetry*)b;
49424         jboolean ret_conv = Retry_eq(a_conv, b_conv);
49425         return ret_conv;
49426 }
49427
49428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1hash(JNIEnv *env, jclass clz, int64_t o) {
49429         LDKRetry* o_conv = (LDKRetry*)o;
49430         int64_t ret_conv = Retry_hash(o_conv);
49431         return ret_conv;
49432 }
49433
49434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49435         if ((this_ptr & 1) != 0) return;
49436         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49437         CHECK_ACCESS(this_ptr_ptr);
49438         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
49439         FREE((void*)this_ptr);
49440         PaymentError_free(this_ptr_conv);
49441 }
49442
49443 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
49444         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49445         *ret_copy = PaymentError_clone(arg);
49446 int64_t ret_ref = (uintptr_t)ret_copy;
49447         return ret_ref;
49448 }
49449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49450         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
49451         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
49452         return ret_conv;
49453 }
49454
49455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49456         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
49457         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49458         *ret_copy = PaymentError_clone(orig_conv);
49459         int64_t ret_ref = (uintptr_t)ret_copy;
49460         return ret_ref;
49461 }
49462
49463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
49464         LDKStr a_conv = java_to_owned_str(env, a);
49465         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49466         *ret_copy = PaymentError_invoice(a_conv);
49467         int64_t ret_ref = (uintptr_t)ret_copy;
49468         return ret_ref;
49469 }
49470
49471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
49472         LDKLightningError a_conv;
49473         a_conv.inner = (void*)(a & (~1));
49474         a_conv.is_owned = (a & 1) || (a == 0);
49475         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49476         a_conv = LightningError_clone(&a_conv);
49477         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49478         *ret_copy = PaymentError_routing(a_conv);
49479         int64_t ret_ref = (uintptr_t)ret_copy;
49480         return ret_ref;
49481 }
49482
49483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
49484         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
49485         CHECK_ACCESS(a_ptr);
49486         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
49487         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
49488         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49489         *ret_copy = PaymentError_sending(a_conv);
49490         int64_t ret_ref = (uintptr_t)ret_copy;
49491         return ret_ref;
49492 }
49493
49494 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) {
49495         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
49496         CHECK_ACCESS(payer_ptr);
49497         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
49498         if (payer_conv.free == LDKPayer_JCalls_free) {
49499                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49500                 LDKPayer_JCalls_cloned(&payer_conv);
49501         }
49502         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
49503         CHECK_ACCESS(router_ptr);
49504         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
49505         if (router_conv.free == LDKRouter_JCalls_free) {
49506                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49507                 LDKRouter_JCalls_cloned(&router_conv);
49508         }
49509         LDKMultiThreadedLockableScore scorer_conv;
49510         scorer_conv.inner = (void*)(scorer & (~1));
49511         scorer_conv.is_owned = false;
49512         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
49513         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
49514         CHECK_ACCESS(logger_ptr);
49515         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
49516         if (logger_conv.free == LDKLogger_JCalls_free) {
49517                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49518                 LDKLogger_JCalls_cloned(&logger_conv);
49519         }
49520         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
49521         CHECK_ACCESS(event_handler_ptr);
49522         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
49523         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
49524                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49525                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
49526         }
49527         void* retry_ptr = (void*)(((uintptr_t)retry) & ~1);
49528         CHECK_ACCESS(retry_ptr);
49529         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
49530         retry_conv = Retry_clone((LDKRetry*)(((uintptr_t)retry) & ~1));
49531         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_conv);
49532         int64_t ret_ref = 0;
49533         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49534         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49536         ret_ref = (uintptr_t)ret_var.inner;
49537         if (ret_var.is_owned) {
49538                 ret_ref |= 1;
49539         }
49540         return ret_ref;
49541 }
49542
49543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
49544         LDKInvoicePayer this_arg_conv;
49545         this_arg_conv.inner = (void*)(this_arg & (~1));
49546         this_arg_conv.is_owned = false;
49547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49548         LDKInvoice invoice_conv;
49549         invoice_conv.inner = (void*)(invoice & (~1));
49550         invoice_conv.is_owned = false;
49551         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
49552         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
49553         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
49554         return (int64_t)ret_conv;
49555 }
49556
49557 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) {
49558         LDKInvoicePayer this_arg_conv;
49559         this_arg_conv.inner = (void*)(this_arg & (~1));
49560         this_arg_conv.is_owned = false;
49561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49562         LDKInvoice invoice_conv;
49563         invoice_conv.inner = (void*)(invoice & (~1));
49564         invoice_conv.is_owned = false;
49565         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
49566         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
49567         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
49568         return (int64_t)ret_conv;
49569 }
49570
49571 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) {
49572         LDKInvoicePayer this_arg_conv;
49573         this_arg_conv.inner = (void*)(this_arg & (~1));
49574         this_arg_conv.is_owned = false;
49575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49576         LDKPublicKey pubkey_ref;
49577         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
49578         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
49579         LDKThirtyTwoBytes payment_preimage_ref;
49580         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
49581         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
49582         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
49583         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
49584         return (int64_t)ret_conv;
49585 }
49586
49587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
49588         LDKInvoicePayer this_arg_conv;
49589         this_arg_conv.inner = (void*)(this_arg & (~1));
49590         this_arg_conv.is_owned = false;
49591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49592         unsigned char payment_hash_arr[32];
49593         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
49594         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
49595         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
49596         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
49597 }
49598
49599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
49600         LDKInvoicePayer this_arg_conv;
49601         this_arg_conv.inner = (void*)(this_arg & (~1));
49602         this_arg_conv.is_owned = false;
49603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49604         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
49605         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
49606         return (int64_t)ret_ret;
49607 }
49608
49609 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) {
49610         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49611         CHECK_ACCESS(amt_msat_ptr);
49612         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49613         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49614         LDKThirtyTwoBytes payment_hash_ref;
49615         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
49616         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
49617         LDKStr description_conv = java_to_owned_str(env, description);
49618         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
49619         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
49620         if (phantom_route_hints_constr.datalen > 0)
49621                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
49622         else
49623                 phantom_route_hints_constr.data = NULL;
49624         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
49625         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
49626                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
49627                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
49628                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
49629                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
49630                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
49631                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
49632                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
49633         }
49634         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
49635         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49636         CHECK_ACCESS(keys_manager_ptr);
49637         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49638         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49639                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49640                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49641         }
49642         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49643         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49644         *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);
49645         return (int64_t)ret_conv;
49646 }
49647
49648 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) {
49649         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49650         CHECK_ACCESS(amt_msat_ptr);
49651         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49652         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49653         LDKThirtyTwoBytes payment_hash_ref;
49654         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
49655         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
49656         LDKSha256 description_hash_conv;
49657         description_hash_conv.inner = (void*)(description_hash & (~1));
49658         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
49659         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
49660         description_hash_conv = Sha256_clone(&description_hash_conv);
49661         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
49662         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
49663         if (phantom_route_hints_constr.datalen > 0)
49664                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
49665         else
49666                 phantom_route_hints_constr.data = NULL;
49667         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
49668         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
49669                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
49670                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
49671                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
49672                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
49673                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
49674                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
49675                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
49676         }
49677         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
49678         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49679         CHECK_ACCESS(keys_manager_ptr);
49680         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49681         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49682                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49683                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49684         }
49685         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49686         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49687         *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);
49688         return (int64_t)ret_conv;
49689 }
49690
49691 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) {
49692         LDKChannelManager channelmanager_conv;
49693         channelmanager_conv.inner = (void*)(channelmanager & (~1));
49694         channelmanager_conv.is_owned = false;
49695         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
49696         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49697         CHECK_ACCESS(keys_manager_ptr);
49698         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49699         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49700                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49701                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49702         }
49703         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49704         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49705         CHECK_ACCESS(amt_msat_ptr);
49706         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49707         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49708         LDKStr description_conv = java_to_owned_str(env, description);
49709         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49710         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv, invoice_expiry_delta_secs);
49711         return (int64_t)ret_conv;
49712 }
49713
49714 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) {
49715         LDKChannelManager channelmanager_conv;
49716         channelmanager_conv.inner = (void*)(channelmanager & (~1));
49717         channelmanager_conv.is_owned = false;
49718         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
49719         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49720         CHECK_ACCESS(keys_manager_ptr);
49721         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49722         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49723                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49724                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49725         }
49726         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49727         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49728         CHECK_ACCESS(amt_msat_ptr);
49729         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49730         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49731         LDKSha256 description_hash_conv;
49732         description_hash_conv.inner = (void*)(description_hash & (~1));
49733         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
49734         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
49735         description_hash_conv = Sha256_clone(&description_hash_conv);
49736         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49737         *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);
49738         return (int64_t)ret_conv;
49739 }
49740
49741 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) {
49742         LDKChannelManager channelmanager_conv;
49743         channelmanager_conv.inner = (void*)(channelmanager & (~1));
49744         channelmanager_conv.is_owned = false;
49745         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
49746         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49747         CHECK_ACCESS(keys_manager_ptr);
49748         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49749         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49750                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49751                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49752         }
49753         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49754         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49755         CHECK_ACCESS(amt_msat_ptr);
49756         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49757         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49758         LDKSha256 description_hash_conv;
49759         description_hash_conv.inner = (void*)(description_hash & (~1));
49760         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
49761         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
49762         description_hash_conv = Sha256_clone(&description_hash_conv);
49763         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49764         *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);
49765         return (int64_t)ret_conv;
49766 }
49767
49768 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) {
49769         LDKChannelManager channelmanager_conv;
49770         channelmanager_conv.inner = (void*)(channelmanager & (~1));
49771         channelmanager_conv.is_owned = false;
49772         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
49773         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49774         CHECK_ACCESS(keys_manager_ptr);
49775         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49776         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49777                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49778                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49779         }
49780         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49781         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49782         CHECK_ACCESS(amt_msat_ptr);
49783         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49784         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49785         LDKStr description_conv = java_to_owned_str(env, description);
49786         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49787         *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);
49788         return (int64_t)ret_conv;
49789 }
49790
49791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49792         LDKDefaultRouter this_obj_conv;
49793         this_obj_conv.inner = (void*)(this_obj & (~1));
49794         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
49795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49796         DefaultRouter_free(this_obj_conv);
49797 }
49798
49799 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) {
49800         LDKNetworkGraph network_graph_conv;
49801         network_graph_conv.inner = (void*)(network_graph & (~1));
49802         network_graph_conv.is_owned = false;
49803         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
49804         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
49805         CHECK_ACCESS(logger_ptr);
49806         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
49807         if (logger_conv.free == LDKLogger_JCalls_free) {
49808                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49809                 LDKLogger_JCalls_cloned(&logger_conv);
49810         }
49811         LDKThirtyTwoBytes random_seed_bytes_ref;
49812         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
49813         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
49814         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
49815         int64_t ret_ref = 0;
49816         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49817         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49819         ret_ref = (uintptr_t)ret_var.inner;
49820         if (ret_var.is_owned) {
49821                 ret_ref |= 1;
49822         }
49823         return ret_ref;
49824 }
49825
49826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
49827         LDKDefaultRouter this_arg_conv;
49828         this_arg_conv.inner = (void*)(this_arg & (~1));
49829         this_arg_conv.is_owned = false;
49830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49831         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
49832         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
49833         return (int64_t)ret_ret;
49834 }
49835
49836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
49837         LDKChannelManager this_arg_conv;
49838         this_arg_conv.inner = (void*)(this_arg & (~1));
49839         this_arg_conv.is_owned = false;
49840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49841         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
49842         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
49843         return (int64_t)ret_ret;
49844 }
49845
49846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
49847         LDKStr s_conv = java_to_owned_str(env, s);
49848         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
49849         *ret_conv = SiPrefix_from_str(s_conv);
49850         return (int64_t)ret_conv;
49851 }
49852
49853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
49854         LDKStr s_conv = java_to_owned_str(env, s);
49855         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
49856         *ret_conv = Invoice_from_str(s_conv);
49857         return (int64_t)ret_conv;
49858 }
49859
49860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
49861         LDKStr s_conv = java_to_owned_str(env, s);
49862         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
49863         *ret_conv = SignedRawInvoice_from_str(s_conv);
49864         return (int64_t)ret_conv;
49865 }
49866
49867 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49868         LDKParseError* o_conv = (LDKParseError*)o;
49869         LDKStr ret_str = ParseError_to_str(o_conv);
49870         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49871         Str_free(ret_str);
49872         return ret_conv;
49873 }
49874
49875 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49876         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
49877         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
49878         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49879         Str_free(ret_str);
49880         return ret_conv;
49881 }
49882
49883 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49884         LDKInvoice o_conv;
49885         o_conv.inner = (void*)(o & (~1));
49886         o_conv.is_owned = false;
49887         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49888         LDKStr ret_str = Invoice_to_str(&o_conv);
49889         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49890         Str_free(ret_str);
49891         return ret_conv;
49892 }
49893
49894 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49895         LDKSignedRawInvoice o_conv;
49896         o_conv.inner = (void*)(o & (~1));
49897         o_conv.is_owned = false;
49898         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49899         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
49900         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49901         Str_free(ret_str);
49902         return ret_conv;
49903 }
49904
49905 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49906         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
49907         LDKStr ret_str = Currency_to_str(o_conv);
49908         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49909         Str_free(ret_str);
49910         return ret_conv;
49911 }
49912
49913 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49914         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
49915         LDKStr ret_str = SiPrefix_to_str(o_conv);
49916         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49917         Str_free(ret_str);
49918         return ret_conv;
49919 }
49920
49921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49922         LDKRapidGossipSync this_obj_conv;
49923         this_obj_conv.inner = (void*)(this_obj & (~1));
49924         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
49925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49926         RapidGossipSync_free(this_obj_conv);
49927 }
49928
49929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph) {
49930         LDKNetworkGraph network_graph_conv;
49931         network_graph_conv.inner = (void*)(network_graph & (~1));
49932         network_graph_conv.is_owned = false;
49933         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
49934         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv);
49935         int64_t ret_ref = 0;
49936         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49937         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49939         ret_ref = (uintptr_t)ret_var.inner;
49940         if (ret_var.is_owned) {
49941                 ret_ref |= 1;
49942         }
49943         return ret_ref;
49944 }
49945
49946 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) {
49947         LDKRapidGossipSync this_arg_conv;
49948         this_arg_conv.inner = (void*)(this_arg & (~1));
49949         this_arg_conv.is_owned = false;
49950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49951         LDKStr sync_path_conv = java_to_owned_str(env, sync_path);
49952         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
49953         *ret_conv = RapidGossipSync_sync_network_graph_with_file_path(&this_arg_conv, sync_path_conv);
49954         return (int64_t)ret_conv;
49955 }
49956
49957 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1is_1initial_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_arg) {
49958         LDKRapidGossipSync this_arg_conv;
49959         this_arg_conv.inner = (void*)(this_arg & (~1));
49960         this_arg_conv.is_owned = false;
49961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49962         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
49963         return ret_conv;
49964 }
49965
49966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49967         if ((this_ptr & 1) != 0) return;
49968         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49969         CHECK_ACCESS(this_ptr_ptr);
49970         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
49971         FREE((void*)this_ptr);
49972         GraphSyncError_free(this_ptr_conv);
49973 }
49974
49975 static inline uintptr_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
49976         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
49977         *ret_copy = GraphSyncError_clone(arg);
49978 int64_t ret_ref = (uintptr_t)ret_copy;
49979         return ret_ref;
49980 }
49981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49982         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)arg;
49983         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
49984         return ret_conv;
49985 }
49986
49987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49988         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)orig;
49989         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
49990         *ret_copy = GraphSyncError_clone(orig_conv);
49991         int64_t ret_ref = (uintptr_t)ret_copy;
49992         return ret_ref;
49993 }
49994
49995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1decode_1error(JNIEnv *env, jclass clz, int64_t a) {
49996         LDKDecodeError a_conv;
49997         a_conv.inner = (void*)(a & (~1));
49998         a_conv.is_owned = (a & 1) || (a == 0);
49999         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50000         a_conv = DecodeError_clone(&a_conv);
50001         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
50002         *ret_copy = GraphSyncError_decode_error(a_conv);
50003         int64_t ret_ref = (uintptr_t)ret_copy;
50004         return ret_ref;
50005 }
50006
50007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1lightning_1error(JNIEnv *env, jclass clz, int64_t a) {
50008         LDKLightningError a_conv;
50009         a_conv.inner = (void*)(a & (~1));
50010         a_conv.is_owned = (a & 1) || (a == 0);
50011         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50012         a_conv = LightningError_clone(&a_conv);
50013         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
50014         *ret_copy = GraphSyncError_lightning_error(a_conv);
50015         int64_t ret_ref = (uintptr_t)ret_copy;
50016         return ret_ref;
50017 }
50018
50019 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) {
50020         LDKRapidGossipSync this_arg_conv;
50021         this_arg_conv.inner = (void*)(this_arg & (~1));
50022         this_arg_conv.is_owned = false;
50023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50024         LDKu8slice update_data_ref;
50025         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
50026         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
50027         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
50028         *ret_conv = RapidGossipSync_update_network_graph(&this_arg_conv, update_data_ref);
50029         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
50030         return (int64_t)ret_conv;
50031 }
50032