[Java] Update auto-generated Java bindings to LDK 0.0.110
[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 void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
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         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28259         CHECK_ACCESS(val_ptr);
28260         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
28261         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
28262         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
28263 }
28264
28265 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28266         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28268         this_ptr_conv.is_owned = false;
28269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28270         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28271         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
28272         return ret_arr;
28273 }
28274
28275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
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         LDKPublicKey val_ref;
28281         CHECK((*env)->GetArrayLength(env, val) == 33);
28282         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28283         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
28284 }
28285
28286 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28287         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28289         this_ptr_conv.is_owned = false;
28290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28291         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28292         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
28293         return ret_arr;
28294 }
28295
28296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
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         LDKThirtyTwoBytes val_ref;
28302         CHECK((*env)->GetArrayLength(env, val) == 32);
28303         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28304         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
28305 }
28306
28307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28308         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28310         this_ptr_conv.is_owned = false;
28311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28312         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
28313         return ret_conv;
28314 }
28315
28316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28317         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28319         this_ptr_conv.is_owned = false;
28320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28321         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
28322 }
28323
28324 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) {
28325         LDKOutPoint outpoint_arg_conv;
28326         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
28327         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
28328         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
28329         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
28330         LDKPublicKey per_commitment_point_arg_ref;
28331         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
28332         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
28333         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
28334         CHECK_ACCESS(output_arg_ptr);
28335         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
28336         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
28337         LDKPublicKey revocation_pubkey_arg_ref;
28338         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
28339         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
28340         LDKThirtyTwoBytes channel_keys_id_arg_ref;
28341         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
28342         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
28343         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);
28344         int64_t ret_ref = 0;
28345         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28346         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28348         ret_ref = (uintptr_t)ret_var.inner;
28349         if (ret_var.is_owned) {
28350                 ret_ref |= 1;
28351         }
28352         return ret_ref;
28353 }
28354
28355 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
28356         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
28357 int64_t ret_ref = 0;
28358 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28359 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28360 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28361 ret_ref = (uintptr_t)ret_var.inner;
28362 if (ret_var.is_owned) {
28363         ret_ref |= 1;
28364 }
28365         return ret_ref;
28366 }
28367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28368         LDKDelayedPaymentOutputDescriptor arg_conv;
28369         arg_conv.inner = (void*)(arg & (~1));
28370         arg_conv.is_owned = false;
28371         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28372         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
28373         return ret_conv;
28374 }
28375
28376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28377         LDKDelayedPaymentOutputDescriptor orig_conv;
28378         orig_conv.inner = (void*)(orig & (~1));
28379         orig_conv.is_owned = false;
28380         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28381         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
28382         int64_t ret_ref = 0;
28383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28386         ret_ref = (uintptr_t)ret_var.inner;
28387         if (ret_var.is_owned) {
28388                 ret_ref |= 1;
28389         }
28390         return ret_ref;
28391 }
28392
28393 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
28394         LDKDelayedPaymentOutputDescriptor obj_conv;
28395         obj_conv.inner = (void*)(obj & (~1));
28396         obj_conv.is_owned = false;
28397         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28398         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
28399         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28400         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28401         CVec_u8Z_free(ret_var);
28402         return ret_arr;
28403 }
28404
28405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28406         LDKu8slice ser_ref;
28407         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28408         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28409         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
28410         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
28411         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28412         return (int64_t)ret_conv;
28413 }
28414
28415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28416         LDKStaticPaymentOutputDescriptor this_obj_conv;
28417         this_obj_conv.inner = (void*)(this_obj & (~1));
28418         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28420         StaticPaymentOutputDescriptor_free(this_obj_conv);
28421 }
28422
28423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28424         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28426         this_ptr_conv.is_owned = false;
28427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28428         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
28429         int64_t ret_ref = 0;
28430         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28431         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28433         ret_ref = (uintptr_t)ret_var.inner;
28434         if (ret_var.is_owned) {
28435                 ret_ref |= 1;
28436         }
28437         return ret_ref;
28438 }
28439
28440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28441         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28443         this_ptr_conv.is_owned = false;
28444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28445         LDKOutPoint val_conv;
28446         val_conv.inner = (void*)(val & (~1));
28447         val_conv.is_owned = (val & 1) || (val == 0);
28448         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28449         val_conv = OutPoint_clone(&val_conv);
28450         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
28451 }
28452
28453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28454         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28456         this_ptr_conv.is_owned = false;
28457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28458         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28459         CHECK_ACCESS(val_ptr);
28460         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
28461         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
28462         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
28463 }
28464
28465 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28466         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28468         this_ptr_conv.is_owned = false;
28469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28470         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28471         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
28472         return ret_arr;
28473 }
28474
28475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28476         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28478         this_ptr_conv.is_owned = false;
28479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28480         LDKThirtyTwoBytes val_ref;
28481         CHECK((*env)->GetArrayLength(env, val) == 32);
28482         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28483         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
28484 }
28485
28486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28487         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28489         this_ptr_conv.is_owned = false;
28490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28491         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
28492         return ret_conv;
28493 }
28494
28495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t 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         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
28501 }
28502
28503 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) {
28504         LDKOutPoint outpoint_arg_conv;
28505         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
28506         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
28507         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
28508         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
28509         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
28510         CHECK_ACCESS(output_arg_ptr);
28511         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
28512         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
28513         LDKThirtyTwoBytes channel_keys_id_arg_ref;
28514         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
28515         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
28516         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
28517         int64_t ret_ref = 0;
28518         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28519         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28521         ret_ref = (uintptr_t)ret_var.inner;
28522         if (ret_var.is_owned) {
28523                 ret_ref |= 1;
28524         }
28525         return ret_ref;
28526 }
28527
28528 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
28529         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
28530 int64_t ret_ref = 0;
28531 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28532 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28533 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28534 ret_ref = (uintptr_t)ret_var.inner;
28535 if (ret_var.is_owned) {
28536         ret_ref |= 1;
28537 }
28538         return ret_ref;
28539 }
28540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28541         LDKStaticPaymentOutputDescriptor arg_conv;
28542         arg_conv.inner = (void*)(arg & (~1));
28543         arg_conv.is_owned = false;
28544         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28545         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
28546         return ret_conv;
28547 }
28548
28549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28550         LDKStaticPaymentOutputDescriptor orig_conv;
28551         orig_conv.inner = (void*)(orig & (~1));
28552         orig_conv.is_owned = false;
28553         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28554         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
28555         int64_t ret_ref = 0;
28556         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28557         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28559         ret_ref = (uintptr_t)ret_var.inner;
28560         if (ret_var.is_owned) {
28561                 ret_ref |= 1;
28562         }
28563         return ret_ref;
28564 }
28565
28566 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
28567         LDKStaticPaymentOutputDescriptor obj_conv;
28568         obj_conv.inner = (void*)(obj & (~1));
28569         obj_conv.is_owned = false;
28570         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28571         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
28572         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28573         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28574         CVec_u8Z_free(ret_var);
28575         return ret_arr;
28576 }
28577
28578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28579         LDKu8slice ser_ref;
28580         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28581         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28582         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
28583         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
28584         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28585         return (int64_t)ret_conv;
28586 }
28587
28588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28589         if ((this_ptr & 1) != 0) return;
28590         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28591         CHECK_ACCESS(this_ptr_ptr);
28592         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
28593         FREE((void*)this_ptr);
28594         SpendableOutputDescriptor_free(this_ptr_conv);
28595 }
28596
28597 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
28598         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28599         *ret_copy = SpendableOutputDescriptor_clone(arg);
28600 int64_t ret_ref = (uintptr_t)ret_copy;
28601         return ret_ref;
28602 }
28603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28604         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
28605         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
28606         return ret_conv;
28607 }
28608
28609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28610         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
28611         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28612         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
28613         int64_t ret_ref = (uintptr_t)ret_copy;
28614         return ret_ref;
28615 }
28616
28617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
28618         LDKOutPoint outpoint_conv;
28619         outpoint_conv.inner = (void*)(outpoint & (~1));
28620         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
28621         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
28622         outpoint_conv = OutPoint_clone(&outpoint_conv);
28623         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
28624         CHECK_ACCESS(output_ptr);
28625         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
28626         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
28627         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28628         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
28629         int64_t ret_ref = (uintptr_t)ret_copy;
28630         return ret_ref;
28631 }
28632
28633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
28634         LDKDelayedPaymentOutputDescriptor a_conv;
28635         a_conv.inner = (void*)(a & (~1));
28636         a_conv.is_owned = (a & 1) || (a == 0);
28637         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28638         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
28639         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28640         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
28641         int64_t ret_ref = (uintptr_t)ret_copy;
28642         return ret_ref;
28643 }
28644
28645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
28646         LDKStaticPaymentOutputDescriptor a_conv;
28647         a_conv.inner = (void*)(a & (~1));
28648         a_conv.is_owned = (a & 1) || (a == 0);
28649         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28650         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
28651         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28652         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
28653         int64_t ret_ref = (uintptr_t)ret_copy;
28654         return ret_ref;
28655 }
28656
28657 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
28658         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
28659         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
28660         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28661         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28662         CVec_u8Z_free(ret_var);
28663         return ret_arr;
28664 }
28665
28666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28667         LDKu8slice ser_ref;
28668         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28669         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28670         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
28671         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
28672         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28673         return (int64_t)ret_conv;
28674 }
28675
28676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28677         if ((this_ptr & 1) != 0) return;
28678         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28679         CHECK_ACCESS(this_ptr_ptr);
28680         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
28681         FREE((void*)this_ptr);
28682         BaseSign_free(this_ptr_conv);
28683 }
28684
28685 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
28686         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
28687         *ret_ret = Sign_clone(arg);
28688         return (int64_t)ret_ret;
28689 }
28690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28691         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
28692         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
28693         LDKSign* arg_conv = (LDKSign*)arg_ptr;
28694         int64_t ret_conv = Sign_clone_ptr(arg_conv);
28695         return ret_conv;
28696 }
28697
28698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28699         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
28700         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
28701         LDKSign* orig_conv = (LDKSign*)orig_ptr;
28702         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
28703         *ret_ret = Sign_clone(orig_conv);
28704         return (int64_t)ret_ret;
28705 }
28706
28707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28708         if ((this_ptr & 1) != 0) return;
28709         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28710         CHECK_ACCESS(this_ptr_ptr);
28711         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
28712         FREE((void*)this_ptr);
28713         Sign_free(this_ptr_conv);
28714 }
28715
28716 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28717         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
28718         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
28719         return ret_conv;
28720 }
28721
28722 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
28723         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
28724         return ret_conv;
28725 }
28726
28727 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
28728         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
28729         return ret_conv;
28730 }
28731
28732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28733         if ((this_ptr & 1) != 0) return;
28734         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28735         CHECK_ACCESS(this_ptr_ptr);
28736         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
28737         FREE((void*)this_ptr);
28738         KeysInterface_free(this_ptr_conv);
28739 }
28740
28741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28742         LDKInMemorySigner this_obj_conv;
28743         this_obj_conv.inner = (void*)(this_obj & (~1));
28744         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28746         InMemorySigner_free(this_obj_conv);
28747 }
28748
28749 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28750         LDKInMemorySigner this_ptr_conv;
28751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28752         this_ptr_conv.is_owned = false;
28753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28754         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28755         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
28756         return ret_arr;
28757 }
28758
28759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28760         LDKInMemorySigner this_ptr_conv;
28761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28762         this_ptr_conv.is_owned = false;
28763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28764         LDKSecretKey val_ref;
28765         CHECK((*env)->GetArrayLength(env, val) == 32);
28766         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28767         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
28768 }
28769
28770 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28771         LDKInMemorySigner this_ptr_conv;
28772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28773         this_ptr_conv.is_owned = false;
28774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28775         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28776         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
28777         return ret_arr;
28778 }
28779
28780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28781         LDKInMemorySigner this_ptr_conv;
28782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28783         this_ptr_conv.is_owned = false;
28784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28785         LDKSecretKey val_ref;
28786         CHECK((*env)->GetArrayLength(env, val) == 32);
28787         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28788         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
28789 }
28790
28791 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28792         LDKInMemorySigner this_ptr_conv;
28793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28794         this_ptr_conv.is_owned = false;
28795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28796         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28797         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
28798         return ret_arr;
28799 }
28800
28801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28802         LDKInMemorySigner this_ptr_conv;
28803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28804         this_ptr_conv.is_owned = false;
28805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28806         LDKSecretKey val_ref;
28807         CHECK((*env)->GetArrayLength(env, val) == 32);
28808         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28809         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
28810 }
28811
28812 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28813         LDKInMemorySigner this_ptr_conv;
28814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28815         this_ptr_conv.is_owned = false;
28816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28817         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28818         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
28819         return ret_arr;
28820 }
28821
28822 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) {
28823         LDKInMemorySigner this_ptr_conv;
28824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28825         this_ptr_conv.is_owned = false;
28826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28827         LDKSecretKey val_ref;
28828         CHECK((*env)->GetArrayLength(env, val) == 32);
28829         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28830         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
28831 }
28832
28833 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28834         LDKInMemorySigner this_ptr_conv;
28835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28836         this_ptr_conv.is_owned = false;
28837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28838         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28839         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
28840         return ret_arr;
28841 }
28842
28843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28844         LDKInMemorySigner this_ptr_conv;
28845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28846         this_ptr_conv.is_owned = false;
28847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28848         LDKSecretKey val_ref;
28849         CHECK((*env)->GetArrayLength(env, val) == 32);
28850         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28851         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
28852 }
28853
28854 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
28855         LDKInMemorySigner this_ptr_conv;
28856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28857         this_ptr_conv.is_owned = false;
28858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28859         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28860         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
28861         return ret_arr;
28862 }
28863
28864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28865         LDKInMemorySigner this_ptr_conv;
28866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28867         this_ptr_conv.is_owned = false;
28868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28869         LDKThirtyTwoBytes val_ref;
28870         CHECK((*env)->GetArrayLength(env, val) == 32);
28871         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28872         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
28873 }
28874
28875 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
28876         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
28877 int64_t ret_ref = 0;
28878 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28879 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28880 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28881 ret_ref = (uintptr_t)ret_var.inner;
28882 if (ret_var.is_owned) {
28883         ret_ref |= 1;
28884 }
28885         return ret_ref;
28886 }
28887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28888         LDKInMemorySigner arg_conv;
28889         arg_conv.inner = (void*)(arg & (~1));
28890         arg_conv.is_owned = false;
28891         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28892         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
28893         return ret_conv;
28894 }
28895
28896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28897         LDKInMemorySigner orig_conv;
28898         orig_conv.inner = (void*)(orig & (~1));
28899         orig_conv.is_owned = false;
28900         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28901         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
28902         int64_t ret_ref = 0;
28903         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28904         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28906         ret_ref = (uintptr_t)ret_var.inner;
28907         if (ret_var.is_owned) {
28908                 ret_ref |= 1;
28909         }
28910         return ret_ref;
28911 }
28912
28913 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) {
28914         LDKSecretKey node_secret_ref;
28915         CHECK((*env)->GetArrayLength(env, node_secret) == 32);
28916         (*env)->GetByteArrayRegion(env, node_secret, 0, 32, node_secret_ref.bytes);
28917         LDKSecretKey funding_key_ref;
28918         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
28919         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
28920         LDKSecretKey revocation_base_key_ref;
28921         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
28922         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
28923         LDKSecretKey payment_key_ref;
28924         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
28925         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
28926         LDKSecretKey delayed_payment_base_key_ref;
28927         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
28928         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
28929         LDKSecretKey htlc_base_key_ref;
28930         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
28931         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
28932         LDKThirtyTwoBytes commitment_seed_ref;
28933         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
28934         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
28935         LDKThirtyTwoBytes channel_keys_id_ref;
28936         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
28937         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
28938         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);
28939         int64_t ret_ref = 0;
28940         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28941         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28943         ret_ref = (uintptr_t)ret_var.inner;
28944         if (ret_var.is_owned) {
28945                 ret_ref |= 1;
28946         }
28947         return ret_ref;
28948 }
28949
28950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
28951         LDKInMemorySigner this_arg_conv;
28952         this_arg_conv.inner = (void*)(this_arg & (~1));
28953         this_arg_conv.is_owned = false;
28954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28955         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
28956         int64_t ret_ref = 0;
28957         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28958         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28960         ret_ref = (uintptr_t)ret_var.inner;
28961         if (ret_var.is_owned) {
28962                 ret_ref |= 1;
28963         }
28964         return ret_ref;
28965 }
28966
28967 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
28968         LDKInMemorySigner this_arg_conv;
28969         this_arg_conv.inner = (void*)(this_arg & (~1));
28970         this_arg_conv.is_owned = false;
28971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28972         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
28973         return ret_conv;
28974 }
28975
28976 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
28977         LDKInMemorySigner this_arg_conv;
28978         this_arg_conv.inner = (void*)(this_arg & (~1));
28979         this_arg_conv.is_owned = false;
28980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28981         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
28982         return ret_conv;
28983 }
28984
28985 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
28986         LDKInMemorySigner this_arg_conv;
28987         this_arg_conv.inner = (void*)(this_arg & (~1));
28988         this_arg_conv.is_owned = false;
28989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28990         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
28991         return ret_conv;
28992 }
28993
28994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
28995         LDKInMemorySigner this_arg_conv;
28996         this_arg_conv.inner = (void*)(this_arg & (~1));
28997         this_arg_conv.is_owned = false;
28998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28999         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
29000         int64_t ret_ref = 0;
29001         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29002         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29004         ret_ref = (uintptr_t)ret_var.inner;
29005         if (ret_var.is_owned) {
29006                 ret_ref |= 1;
29007         }
29008         return ret_ref;
29009 }
29010
29011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
29012         LDKInMemorySigner this_arg_conv;
29013         this_arg_conv.inner = (void*)(this_arg & (~1));
29014         this_arg_conv.is_owned = false;
29015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29016         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
29017         int64_t ret_ref = 0;
29018         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29019         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29021         ret_ref = (uintptr_t)ret_var.inner;
29022         if (ret_var.is_owned) {
29023                 ret_ref |= 1;
29024         }
29025         return ret_ref;
29026 }
29027
29028 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
29029         LDKInMemorySigner this_arg_conv;
29030         this_arg_conv.inner = (void*)(this_arg & (~1));
29031         this_arg_conv.is_owned = false;
29032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29033         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
29034         return ret_conv;
29035 }
29036
29037 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) {
29038         LDKInMemorySigner this_arg_conv;
29039         this_arg_conv.inner = (void*)(this_arg & (~1));
29040         this_arg_conv.is_owned = false;
29041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29042         LDKTransaction spend_tx_ref;
29043         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
29044         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
29045         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
29046         spend_tx_ref.data_is_owned = true;
29047         LDKStaticPaymentOutputDescriptor descriptor_conv;
29048         descriptor_conv.inner = (void*)(descriptor & (~1));
29049         descriptor_conv.is_owned = false;
29050         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
29051         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
29052         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
29053         return (int64_t)ret_conv;
29054 }
29055
29056 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) {
29057         LDKInMemorySigner this_arg_conv;
29058         this_arg_conv.inner = (void*)(this_arg & (~1));
29059         this_arg_conv.is_owned = false;
29060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29061         LDKTransaction spend_tx_ref;
29062         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
29063         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
29064         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
29065         spend_tx_ref.data_is_owned = true;
29066         LDKDelayedPaymentOutputDescriptor descriptor_conv;
29067         descriptor_conv.inner = (void*)(descriptor & (~1));
29068         descriptor_conv.is_owned = false;
29069         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
29070         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
29071         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
29072         return (int64_t)ret_conv;
29073 }
29074
29075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
29076         LDKInMemorySigner this_arg_conv;
29077         this_arg_conv.inner = (void*)(this_arg & (~1));
29078         this_arg_conv.is_owned = false;
29079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29080         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
29081         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
29082         return (int64_t)ret_ret;
29083 }
29084
29085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
29086         LDKInMemorySigner this_arg_conv;
29087         this_arg_conv.inner = (void*)(this_arg & (~1));
29088         this_arg_conv.is_owned = false;
29089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29090         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
29091         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
29092         return (int64_t)ret_ret;
29093 }
29094
29095 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
29096         LDKInMemorySigner obj_conv;
29097         obj_conv.inner = (void*)(obj & (~1));
29098         obj_conv.is_owned = false;
29099         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29100         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
29101         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29102         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29103         CVec_u8Z_free(ret_var);
29104         return ret_arr;
29105 }
29106
29107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int8_tArray arg) {
29108         LDKu8slice ser_ref;
29109         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29110         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29111         LDKSecretKey arg_ref;
29112         CHECK((*env)->GetArrayLength(env, arg) == 32);
29113         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
29114         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
29115         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
29116         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29117         return (int64_t)ret_conv;
29118 }
29119
29120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29121         LDKKeysManager this_obj_conv;
29122         this_obj_conv.inner = (void*)(this_obj & (~1));
29123         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29125         KeysManager_free(this_obj_conv);
29126 }
29127
29128 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) {
29129         unsigned char seed_arr[32];
29130         CHECK((*env)->GetArrayLength(env, seed) == 32);
29131         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
29132         unsigned char (*seed_ref)[32] = &seed_arr;
29133         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
29134         int64_t ret_ref = 0;
29135         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29136         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29137         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29138         ret_ref = (uintptr_t)ret_var.inner;
29139         if (ret_var.is_owned) {
29140                 ret_ref |= 1;
29141         }
29142         return ret_ref;
29143 }
29144
29145 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) {
29146         LDKKeysManager this_arg_conv;
29147         this_arg_conv.inner = (void*)(this_arg & (~1));
29148         this_arg_conv.is_owned = false;
29149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29150         unsigned char params_arr[32];
29151         CHECK((*env)->GetArrayLength(env, params) == 32);
29152         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
29153         unsigned char (*params_ref)[32] = &params_arr;
29154         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
29155         int64_t ret_ref = 0;
29156         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29157         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29159         ret_ref = (uintptr_t)ret_var.inner;
29160         if (ret_var.is_owned) {
29161                 ret_ref |= 1;
29162         }
29163         return ret_ref;
29164 }
29165
29166 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) {
29167         LDKKeysManager this_arg_conv;
29168         this_arg_conv.inner = (void*)(this_arg & (~1));
29169         this_arg_conv.is_owned = false;
29170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29171         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
29172         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
29173         if (descriptors_constr.datalen > 0)
29174                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
29175         else
29176                 descriptors_constr.data = NULL;
29177         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
29178         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
29179                 int64_t descriptors_conv_27 = descriptors_vals[b];
29180                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
29181                 CHECK_ACCESS(descriptors_conv_27_ptr);
29182                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
29183                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
29184                 descriptors_constr.data[b] = descriptors_conv_27_conv;
29185         }
29186         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
29187         LDKCVec_TxOutZ outputs_constr;
29188         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
29189         if (outputs_constr.datalen > 0)
29190                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
29191         else
29192                 outputs_constr.data = NULL;
29193         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
29194         for (size_t h = 0; h < outputs_constr.datalen; h++) {
29195                 int64_t outputs_conv_7 = outputs_vals[h];
29196                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
29197                 CHECK_ACCESS(outputs_conv_7_ptr);
29198                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
29199                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
29200                 outputs_constr.data[h] = outputs_conv_7_conv;
29201         }
29202         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
29203         LDKCVec_u8Z change_destination_script_ref;
29204         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
29205         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
29206         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
29207         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
29208         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
29209         return (int64_t)ret_conv;
29210 }
29211
29212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
29213         LDKKeysManager this_arg_conv;
29214         this_arg_conv.inner = (void*)(this_arg & (~1));
29215         this_arg_conv.is_owned = false;
29216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29217         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
29218         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
29219         return (int64_t)ret_ret;
29220 }
29221
29222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29223         LDKPhantomKeysManager this_obj_conv;
29224         this_obj_conv.inner = (void*)(this_obj & (~1));
29225         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29227         PhantomKeysManager_free(this_obj_conv);
29228 }
29229
29230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
29231         LDKPhantomKeysManager this_arg_conv;
29232         this_arg_conv.inner = (void*)(this_arg & (~1));
29233         this_arg_conv.is_owned = false;
29234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29235         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
29236         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
29237         return (int64_t)ret_ret;
29238 }
29239
29240 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) {
29241         unsigned char seed_arr[32];
29242         CHECK((*env)->GetArrayLength(env, seed) == 32);
29243         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
29244         unsigned char (*seed_ref)[32] = &seed_arr;
29245         unsigned char cross_node_seed_arr[32];
29246         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
29247         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
29248         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
29249         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
29250         int64_t ret_ref = 0;
29251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29254         ret_ref = (uintptr_t)ret_var.inner;
29255         if (ret_var.is_owned) {
29256                 ret_ref |= 1;
29257         }
29258         return ret_ref;
29259 }
29260
29261 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) {
29262         LDKPhantomKeysManager this_arg_conv;
29263         this_arg_conv.inner = (void*)(this_arg & (~1));
29264         this_arg_conv.is_owned = false;
29265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29266         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
29267         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
29268         if (descriptors_constr.datalen > 0)
29269                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
29270         else
29271                 descriptors_constr.data = NULL;
29272         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
29273         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
29274                 int64_t descriptors_conv_27 = descriptors_vals[b];
29275                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
29276                 CHECK_ACCESS(descriptors_conv_27_ptr);
29277                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
29278                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
29279                 descriptors_constr.data[b] = descriptors_conv_27_conv;
29280         }
29281         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
29282         LDKCVec_TxOutZ outputs_constr;
29283         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
29284         if (outputs_constr.datalen > 0)
29285                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
29286         else
29287                 outputs_constr.data = NULL;
29288         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
29289         for (size_t h = 0; h < outputs_constr.datalen; h++) {
29290                 int64_t outputs_conv_7 = outputs_vals[h];
29291                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
29292                 CHECK_ACCESS(outputs_conv_7_ptr);
29293                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
29294                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
29295                 outputs_constr.data[h] = outputs_conv_7_conv;
29296         }
29297         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
29298         LDKCVec_u8Z change_destination_script_ref;
29299         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
29300         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
29301         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
29302         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
29303         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
29304         return (int64_t)ret_conv;
29305 }
29306
29307 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) {
29308         LDKPhantomKeysManager this_arg_conv;
29309         this_arg_conv.inner = (void*)(this_arg & (~1));
29310         this_arg_conv.is_owned = false;
29311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29312         unsigned char params_arr[32];
29313         CHECK((*env)->GetArrayLength(env, params) == 32);
29314         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
29315         unsigned char (*params_ref)[32] = &params_arr;
29316         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
29317         int64_t ret_ref = 0;
29318         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29319         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29321         ret_ref = (uintptr_t)ret_var.inner;
29322         if (ret_var.is_owned) {
29323                 ret_ref |= 1;
29324         }
29325         return ret_ref;
29326 }
29327
29328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29329         LDKChannelManager this_obj_conv;
29330         this_obj_conv.inner = (void*)(this_obj & (~1));
29331         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29333         ChannelManager_free(this_obj_conv);
29334 }
29335
29336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29337         LDKChainParameters this_obj_conv;
29338         this_obj_conv.inner = (void*)(this_obj & (~1));
29339         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29341         ChainParameters_free(this_obj_conv);
29342 }
29343
29344 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
29345         LDKChainParameters this_ptr_conv;
29346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29347         this_ptr_conv.is_owned = false;
29348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29349         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
29350         return ret_conv;
29351 }
29352
29353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
29354         LDKChainParameters this_ptr_conv;
29355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29356         this_ptr_conv.is_owned = false;
29357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29358         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
29359         ChainParameters_set_network(&this_ptr_conv, val_conv);
29360 }
29361
29362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
29363         LDKChainParameters this_ptr_conv;
29364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29365         this_ptr_conv.is_owned = false;
29366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29367         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
29368         int64_t ret_ref = 0;
29369         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29370         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29372         ret_ref = (uintptr_t)ret_var.inner;
29373         if (ret_var.is_owned) {
29374                 ret_ref |= 1;
29375         }
29376         return ret_ref;
29377 }
29378
29379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29380         LDKChainParameters this_ptr_conv;
29381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29382         this_ptr_conv.is_owned = false;
29383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29384         LDKBestBlock val_conv;
29385         val_conv.inner = (void*)(val & (~1));
29386         val_conv.is_owned = (val & 1) || (val == 0);
29387         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29388         val_conv = BestBlock_clone(&val_conv);
29389         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
29390 }
29391
29392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
29393         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
29394         LDKBestBlock best_block_arg_conv;
29395         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
29396         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
29397         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
29398         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
29399         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
29400         int64_t ret_ref = 0;
29401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29404         ret_ref = (uintptr_t)ret_var.inner;
29405         if (ret_var.is_owned) {
29406                 ret_ref |= 1;
29407         }
29408         return ret_ref;
29409 }
29410
29411 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
29412         LDKChainParameters ret_var = ChainParameters_clone(arg);
29413 int64_t ret_ref = 0;
29414 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29415 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29416 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29417 ret_ref = (uintptr_t)ret_var.inner;
29418 if (ret_var.is_owned) {
29419         ret_ref |= 1;
29420 }
29421         return ret_ref;
29422 }
29423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29424         LDKChainParameters arg_conv;
29425         arg_conv.inner = (void*)(arg & (~1));
29426         arg_conv.is_owned = false;
29427         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29428         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
29429         return ret_conv;
29430 }
29431
29432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29433         LDKChainParameters orig_conv;
29434         orig_conv.inner = (void*)(orig & (~1));
29435         orig_conv.is_owned = false;
29436         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29437         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
29438         int64_t ret_ref = 0;
29439         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29440         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29442         ret_ref = (uintptr_t)ret_var.inner;
29443         if (ret_var.is_owned) {
29444                 ret_ref |= 1;
29445         }
29446         return ret_ref;
29447 }
29448
29449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29450         LDKCounterpartyForwardingInfo this_obj_conv;
29451         this_obj_conv.inner = (void*)(this_obj & (~1));
29452         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29454         CounterpartyForwardingInfo_free(this_obj_conv);
29455 }
29456
29457 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29458         LDKCounterpartyForwardingInfo this_ptr_conv;
29459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29460         this_ptr_conv.is_owned = false;
29461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29462         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
29463         return ret_conv;
29464 }
29465
29466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29467         LDKCounterpartyForwardingInfo this_ptr_conv;
29468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29469         this_ptr_conv.is_owned = false;
29470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29471         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
29472 }
29473
29474 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
29475         LDKCounterpartyForwardingInfo this_ptr_conv;
29476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29477         this_ptr_conv.is_owned = false;
29478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29479         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
29480         return ret_conv;
29481 }
29482
29483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29484         LDKCounterpartyForwardingInfo this_ptr_conv;
29485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29486         this_ptr_conv.is_owned = false;
29487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29488         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
29489 }
29490
29491 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
29492         LDKCounterpartyForwardingInfo this_ptr_conv;
29493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29494         this_ptr_conv.is_owned = false;
29495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29496         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
29497         return ret_conv;
29498 }
29499
29500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29501         LDKCounterpartyForwardingInfo this_ptr_conv;
29502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29503         this_ptr_conv.is_owned = false;
29504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29505         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
29506 }
29507
29508 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) {
29509         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
29510         int64_t ret_ref = 0;
29511         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29512         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29514         ret_ref = (uintptr_t)ret_var.inner;
29515         if (ret_var.is_owned) {
29516                 ret_ref |= 1;
29517         }
29518         return ret_ref;
29519 }
29520
29521 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
29522         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
29523 int64_t ret_ref = 0;
29524 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29525 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29526 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29527 ret_ref = (uintptr_t)ret_var.inner;
29528 if (ret_var.is_owned) {
29529         ret_ref |= 1;
29530 }
29531         return ret_ref;
29532 }
29533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29534         LDKCounterpartyForwardingInfo arg_conv;
29535         arg_conv.inner = (void*)(arg & (~1));
29536         arg_conv.is_owned = false;
29537         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29538         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
29539         return ret_conv;
29540 }
29541
29542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29543         LDKCounterpartyForwardingInfo orig_conv;
29544         orig_conv.inner = (void*)(orig & (~1));
29545         orig_conv.is_owned = false;
29546         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29547         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
29548         int64_t ret_ref = 0;
29549         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29550         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29552         ret_ref = (uintptr_t)ret_var.inner;
29553         if (ret_var.is_owned) {
29554                 ret_ref |= 1;
29555         }
29556         return ret_ref;
29557 }
29558
29559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29560         LDKChannelCounterparty this_obj_conv;
29561         this_obj_conv.inner = (void*)(this_obj & (~1));
29562         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29564         ChannelCounterparty_free(this_obj_conv);
29565 }
29566
29567 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29568         LDKChannelCounterparty this_ptr_conv;
29569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29570         this_ptr_conv.is_owned = false;
29571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29572         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29573         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
29574         return ret_arr;
29575 }
29576
29577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29578         LDKChannelCounterparty this_ptr_conv;
29579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29580         this_ptr_conv.is_owned = false;
29581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29582         LDKPublicKey val_ref;
29583         CHECK((*env)->GetArrayLength(env, val) == 33);
29584         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29585         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
29586 }
29587
29588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
29589         LDKChannelCounterparty this_ptr_conv;
29590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29591         this_ptr_conv.is_owned = false;
29592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29593         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
29594         int64_t ret_ref = 0;
29595         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29596         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29598         ret_ref = (uintptr_t)ret_var.inner;
29599         if (ret_var.is_owned) {
29600                 ret_ref |= 1;
29601         }
29602         return ret_ref;
29603 }
29604
29605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29606         LDKChannelCounterparty this_ptr_conv;
29607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29608         this_ptr_conv.is_owned = false;
29609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29610         LDKInitFeatures val_conv;
29611         val_conv.inner = (void*)(val & (~1));
29612         val_conv.is_owned = (val & 1) || (val == 0);
29613         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29614         val_conv = InitFeatures_clone(&val_conv);
29615         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
29616 }
29617
29618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
29619         LDKChannelCounterparty this_ptr_conv;
29620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29621         this_ptr_conv.is_owned = false;
29622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29623         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
29624         return ret_conv;
29625 }
29626
29627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29628         LDKChannelCounterparty this_ptr_conv;
29629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29630         this_ptr_conv.is_owned = false;
29631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29632         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
29633 }
29634
29635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
29636         LDKChannelCounterparty this_ptr_conv;
29637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29638         this_ptr_conv.is_owned = false;
29639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29640         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
29641         int64_t ret_ref = 0;
29642         if ((uintptr_t)ret_var.inner > 4096) {
29643                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29644                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29646                 ret_ref = (uintptr_t)ret_var.inner;
29647                 if (ret_var.is_owned) {
29648                         ret_ref |= 1;
29649                 }
29650         }
29651         return ret_ref;
29652 }
29653
29654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29655         LDKChannelCounterparty this_ptr_conv;
29656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29657         this_ptr_conv.is_owned = false;
29658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29659         LDKCounterpartyForwardingInfo val_conv;
29660         val_conv.inner = (void*)(val & (~1));
29661         val_conv.is_owned = (val & 1) || (val == 0);
29662         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29663         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
29664         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
29665 }
29666
29667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29668         LDKChannelCounterparty this_ptr_conv;
29669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29670         this_ptr_conv.is_owned = false;
29671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29672         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29673         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
29674         int64_t ret_ref = (uintptr_t)ret_copy;
29675         return ret_ref;
29676 }
29677
29678 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) {
29679         LDKChannelCounterparty this_ptr_conv;
29680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29681         this_ptr_conv.is_owned = false;
29682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29683         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29684         CHECK_ACCESS(val_ptr);
29685         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29686         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29687         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
29688 }
29689
29690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29691         LDKChannelCounterparty this_ptr_conv;
29692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29693         this_ptr_conv.is_owned = false;
29694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29695         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29696         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
29697         int64_t ret_ref = (uintptr_t)ret_copy;
29698         return ret_ref;
29699 }
29700
29701 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) {
29702         LDKChannelCounterparty this_ptr_conv;
29703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29704         this_ptr_conv.is_owned = false;
29705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29706         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29707         CHECK_ACCESS(val_ptr);
29708         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29709         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29710         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
29711 }
29712
29713 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) {
29714         LDKPublicKey node_id_arg_ref;
29715         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
29716         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
29717         LDKInitFeatures features_arg_conv;
29718         features_arg_conv.inner = (void*)(features_arg & (~1));
29719         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
29720         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
29721         features_arg_conv = InitFeatures_clone(&features_arg_conv);
29722         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
29723         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
29724         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
29725         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
29726         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
29727         void* outbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1);
29728         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
29729         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
29730         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1));
29731         void* outbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1);
29732         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
29733         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
29734         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1));
29735         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);
29736         int64_t ret_ref = 0;
29737         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29738         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29740         ret_ref = (uintptr_t)ret_var.inner;
29741         if (ret_var.is_owned) {
29742                 ret_ref |= 1;
29743         }
29744         return ret_ref;
29745 }
29746
29747 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
29748         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
29749 int64_t ret_ref = 0;
29750 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29751 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29752 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29753 ret_ref = (uintptr_t)ret_var.inner;
29754 if (ret_var.is_owned) {
29755         ret_ref |= 1;
29756 }
29757         return ret_ref;
29758 }
29759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29760         LDKChannelCounterparty arg_conv;
29761         arg_conv.inner = (void*)(arg & (~1));
29762         arg_conv.is_owned = false;
29763         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29764         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
29765         return ret_conv;
29766 }
29767
29768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29769         LDKChannelCounterparty orig_conv;
29770         orig_conv.inner = (void*)(orig & (~1));
29771         orig_conv.is_owned = false;
29772         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29773         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
29774         int64_t ret_ref = 0;
29775         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29776         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29778         ret_ref = (uintptr_t)ret_var.inner;
29779         if (ret_var.is_owned) {
29780                 ret_ref |= 1;
29781         }
29782         return ret_ref;
29783 }
29784
29785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29786         LDKChannelDetails this_obj_conv;
29787         this_obj_conv.inner = (void*)(this_obj & (~1));
29788         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29790         ChannelDetails_free(this_obj_conv);
29791 }
29792
29793 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29794         LDKChannelDetails this_ptr_conv;
29795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29796         this_ptr_conv.is_owned = false;
29797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29798         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29799         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
29800         return ret_arr;
29801 }
29802
29803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29804         LDKChannelDetails this_ptr_conv;
29805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29806         this_ptr_conv.is_owned = false;
29807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29808         LDKThirtyTwoBytes val_ref;
29809         CHECK((*env)->GetArrayLength(env, val) == 32);
29810         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29811         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
29812 }
29813
29814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
29815         LDKChannelDetails this_ptr_conv;
29816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29817         this_ptr_conv.is_owned = false;
29818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29819         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
29820         int64_t ret_ref = 0;
29821         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29822         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29824         ret_ref = (uintptr_t)ret_var.inner;
29825         if (ret_var.is_owned) {
29826                 ret_ref |= 1;
29827         }
29828         return ret_ref;
29829 }
29830
29831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29832         LDKChannelDetails this_ptr_conv;
29833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29834         this_ptr_conv.is_owned = false;
29835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29836         LDKChannelCounterparty val_conv;
29837         val_conv.inner = (void*)(val & (~1));
29838         val_conv.is_owned = (val & 1) || (val == 0);
29839         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29840         val_conv = ChannelCounterparty_clone(&val_conv);
29841         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
29842 }
29843
29844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
29845         LDKChannelDetails this_ptr_conv;
29846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29847         this_ptr_conv.is_owned = false;
29848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29849         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
29850         int64_t ret_ref = 0;
29851         if ((uintptr_t)ret_var.inner > 4096) {
29852                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29853                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29855                 ret_ref = (uintptr_t)ret_var.inner;
29856                 if (ret_var.is_owned) {
29857                         ret_ref |= 1;
29858                 }
29859         }
29860         return ret_ref;
29861 }
29862
29863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29864         LDKChannelDetails this_ptr_conv;
29865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29866         this_ptr_conv.is_owned = false;
29867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29868         LDKOutPoint val_conv;
29869         val_conv.inner = (void*)(val & (~1));
29870         val_conv.is_owned = (val & 1) || (val == 0);
29871         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29872         val_conv = OutPoint_clone(&val_conv);
29873         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
29874 }
29875
29876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
29877         LDKChannelDetails this_ptr_conv;
29878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29879         this_ptr_conv.is_owned = false;
29880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29881         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
29882         int64_t ret_ref = 0;
29883         if ((uintptr_t)ret_var.inner > 4096) {
29884                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29885                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29887                 ret_ref = (uintptr_t)ret_var.inner;
29888                 if (ret_var.is_owned) {
29889                         ret_ref |= 1;
29890                 }
29891         }
29892         return ret_ref;
29893 }
29894
29895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29896         LDKChannelDetails this_ptr_conv;
29897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29898         this_ptr_conv.is_owned = false;
29899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29900         LDKChannelTypeFeatures val_conv;
29901         val_conv.inner = (void*)(val & (~1));
29902         val_conv.is_owned = (val & 1) || (val == 0);
29903         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29904         val_conv = ChannelTypeFeatures_clone(&val_conv);
29905         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
29906 }
29907
29908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29909         LDKChannelDetails this_ptr_conv;
29910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29911         this_ptr_conv.is_owned = false;
29912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29913         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29914         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
29915         int64_t ret_ref = (uintptr_t)ret_copy;
29916         return ret_ref;
29917 }
29918
29919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29920         LDKChannelDetails this_ptr_conv;
29921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29922         this_ptr_conv.is_owned = false;
29923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29924         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29925         CHECK_ACCESS(val_ptr);
29926         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29927         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29928         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
29929 }
29930
29931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
29932         LDKChannelDetails this_ptr_conv;
29933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29934         this_ptr_conv.is_owned = false;
29935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29936         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29937         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
29938         int64_t ret_ref = (uintptr_t)ret_copy;
29939         return ret_ref;
29940 }
29941
29942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29943         LDKChannelDetails this_ptr_conv;
29944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29945         this_ptr_conv.is_owned = false;
29946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29947         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29948         CHECK_ACCESS(val_ptr);
29949         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29950         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29951         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
29952 }
29953
29954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
29955         LDKChannelDetails this_ptr_conv;
29956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29957         this_ptr_conv.is_owned = false;
29958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29959         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29960         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
29961         int64_t ret_ref = (uintptr_t)ret_copy;
29962         return ret_ref;
29963 }
29964
29965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29966         LDKChannelDetails this_ptr_conv;
29967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29968         this_ptr_conv.is_owned = false;
29969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29970         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29971         CHECK_ACCESS(val_ptr);
29972         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29973         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29974         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
29975 }
29976
29977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29978         LDKChannelDetails this_ptr_conv;
29979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29980         this_ptr_conv.is_owned = false;
29981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29982         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
29983         return ret_conv;
29984 }
29985
29986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29987         LDKChannelDetails this_ptr_conv;
29988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29989         this_ptr_conv.is_owned = false;
29990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29991         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
29992 }
29993
29994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
29995         LDKChannelDetails this_ptr_conv;
29996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29997         this_ptr_conv.is_owned = false;
29998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29999         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30000         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
30001         int64_t ret_ref = (uintptr_t)ret_copy;
30002         return ret_ref;
30003 }
30004
30005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30006         LDKChannelDetails this_ptr_conv;
30007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30008         this_ptr_conv.is_owned = false;
30009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30010         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30011         CHECK_ACCESS(val_ptr);
30012         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30013         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
30014         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
30015 }
30016
30017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30018         LDKChannelDetails this_ptr_conv;
30019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30020         this_ptr_conv.is_owned = false;
30021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30022         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
30023         return ret_conv;
30024 }
30025
30026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30027         LDKChannelDetails this_ptr_conv;
30028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30029         this_ptr_conv.is_owned = false;
30030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30031         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
30032 }
30033
30034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30035         LDKChannelDetails this_ptr_conv;
30036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30037         this_ptr_conv.is_owned = false;
30038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30039         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
30040         return ret_conv;
30041 }
30042
30043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30044         LDKChannelDetails this_ptr_conv;
30045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30046         this_ptr_conv.is_owned = false;
30047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30048         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
30049 }
30050
30051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30052         LDKChannelDetails this_ptr_conv;
30053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30054         this_ptr_conv.is_owned = false;
30055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30056         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
30057         return ret_conv;
30058 }
30059
30060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30061         LDKChannelDetails this_ptr_conv;
30062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30063         this_ptr_conv.is_owned = false;
30064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30065         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
30066 }
30067
30068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30069         LDKChannelDetails this_ptr_conv;
30070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30071         this_ptr_conv.is_owned = false;
30072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30073         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
30074         return ret_conv;
30075 }
30076
30077 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) {
30078         LDKChannelDetails this_ptr_conv;
30079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30080         this_ptr_conv.is_owned = false;
30081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30082         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
30083 }
30084
30085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30086         LDKChannelDetails this_ptr_conv;
30087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30088         this_ptr_conv.is_owned = false;
30089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30090         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
30091         return ret_conv;
30092 }
30093
30094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30095         LDKChannelDetails this_ptr_conv;
30096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30097         this_ptr_conv.is_owned = false;
30098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30099         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
30100 }
30101
30102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
30103         LDKChannelDetails this_ptr_conv;
30104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30105         this_ptr_conv.is_owned = false;
30106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30107         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
30108         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
30109         int64_t ret_ref = (uintptr_t)ret_copy;
30110         return ret_ref;
30111 }
30112
30113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30114         LDKChannelDetails this_ptr_conv;
30115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30116         this_ptr_conv.is_owned = false;
30117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30118         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30119         CHECK_ACCESS(val_ptr);
30120         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
30121         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
30122         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
30123 }
30124
30125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30126         LDKChannelDetails this_ptr_conv;
30127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30128         this_ptr_conv.is_owned = false;
30129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30130         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
30131         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
30132         int64_t ret_ref = (uintptr_t)ret_copy;
30133         return ret_ref;
30134 }
30135
30136 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) {
30137         LDKChannelDetails this_ptr_conv;
30138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30139         this_ptr_conv.is_owned = false;
30140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30141         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30142         CHECK_ACCESS(val_ptr);
30143         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
30144         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
30145         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
30146 }
30147
30148 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
30149         LDKChannelDetails this_ptr_conv;
30150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30151         this_ptr_conv.is_owned = false;
30152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30153         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
30154         return ret_conv;
30155 }
30156
30157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30158         LDKChannelDetails this_ptr_conv;
30159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30160         this_ptr_conv.is_owned = false;
30161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30162         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
30163 }
30164
30165 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr) {
30166         LDKChannelDetails this_ptr_conv;
30167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30168         this_ptr_conv.is_owned = false;
30169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30170         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
30171         return ret_conv;
30172 }
30173
30174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30175         LDKChannelDetails this_ptr_conv;
30176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30177         this_ptr_conv.is_owned = false;
30178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30179         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
30180 }
30181
30182 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
30183         LDKChannelDetails this_ptr_conv;
30184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30185         this_ptr_conv.is_owned = false;
30186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30187         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
30188         return ret_conv;
30189 }
30190
30191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30192         LDKChannelDetails this_ptr_conv;
30193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30194         this_ptr_conv.is_owned = false;
30195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30196         ChannelDetails_set_is_usable(&this_ptr_conv, val);
30197 }
30198
30199 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
30200         LDKChannelDetails this_ptr_conv;
30201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30202         this_ptr_conv.is_owned = false;
30203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30204         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
30205         return ret_conv;
30206 }
30207
30208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30209         LDKChannelDetails this_ptr_conv;
30210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30211         this_ptr_conv.is_owned = false;
30212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30213         ChannelDetails_set_is_public(&this_ptr_conv, val);
30214 }
30215
30216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30217         LDKChannelDetails this_ptr_conv;
30218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30219         this_ptr_conv.is_owned = false;
30220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30221         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30222         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
30223         int64_t ret_ref = (uintptr_t)ret_copy;
30224         return ret_ref;
30225 }
30226
30227 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) {
30228         LDKChannelDetails this_ptr_conv;
30229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30230         this_ptr_conv.is_owned = false;
30231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30232         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30233         CHECK_ACCESS(val_ptr);
30234         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30235         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
30236         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
30237 }
30238
30239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30240         LDKChannelDetails this_ptr_conv;
30241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30242         this_ptr_conv.is_owned = false;
30243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30244         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30245         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
30246         int64_t ret_ref = (uintptr_t)ret_copy;
30247         return ret_ref;
30248 }
30249
30250 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) {
30251         LDKChannelDetails this_ptr_conv;
30252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30253         this_ptr_conv.is_owned = false;
30254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30255         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30256         CHECK_ACCESS(val_ptr);
30257         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30258         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
30259         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
30260 }
30261
30262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
30263         LDKChannelDetails this_ptr_conv;
30264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30265         this_ptr_conv.is_owned = false;
30266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30267         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
30268         int64_t ret_ref = 0;
30269         if ((uintptr_t)ret_var.inner > 4096) {
30270                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30271                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30272         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30273                 ret_ref = (uintptr_t)ret_var.inner;
30274                 if (ret_var.is_owned) {
30275                         ret_ref |= 1;
30276                 }
30277         }
30278         return ret_ref;
30279 }
30280
30281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30282         LDKChannelDetails this_ptr_conv;
30283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30284         this_ptr_conv.is_owned = false;
30285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30286         LDKChannelConfig val_conv;
30287         val_conv.inner = (void*)(val & (~1));
30288         val_conv.is_owned = (val & 1) || (val == 0);
30289         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30290         val_conv = ChannelConfig_clone(&val_conv);
30291         ChannelDetails_set_config(&this_ptr_conv, val_conv);
30292 }
30293
30294 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) {
30295         LDKThirtyTwoBytes channel_id_arg_ref;
30296         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30297         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30298         LDKChannelCounterparty counterparty_arg_conv;
30299         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
30300         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
30301         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
30302         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
30303         LDKOutPoint funding_txo_arg_conv;
30304         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
30305         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
30306         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
30307         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
30308         LDKChannelTypeFeatures channel_type_arg_conv;
30309         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
30310         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
30311         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
30312         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
30313         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
30314         CHECK_ACCESS(short_channel_id_arg_ptr);
30315         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
30316         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
30317         void* outbound_scid_alias_arg_ptr = (void*)(((uintptr_t)outbound_scid_alias_arg) & ~1);
30318         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
30319         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
30320         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_scid_alias_arg) & ~1));
30321         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
30322         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
30323         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
30324         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
30325         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
30326         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
30327         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
30328         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
30329         CHECK_ACCESS(confirmations_required_arg_ptr);
30330         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
30331         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
30332         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
30333         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
30334         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
30335         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
30336         void* inbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1);
30337         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
30338         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
30339         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1));
30340         void* inbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1);
30341         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
30342         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
30343         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1));
30344         LDKChannelConfig config_arg_conv;
30345         config_arg_conv.inner = (void*)(config_arg & (~1));
30346         config_arg_conv.is_owned = (config_arg & 1) || (config_arg == 0);
30347         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
30348         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
30349         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);
30350         int64_t ret_ref = 0;
30351         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30352         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30354         ret_ref = (uintptr_t)ret_var.inner;
30355         if (ret_var.is_owned) {
30356                 ret_ref |= 1;
30357         }
30358         return ret_ref;
30359 }
30360
30361 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
30362         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
30363 int64_t ret_ref = 0;
30364 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30365 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30366 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30367 ret_ref = (uintptr_t)ret_var.inner;
30368 if (ret_var.is_owned) {
30369         ret_ref |= 1;
30370 }
30371         return ret_ref;
30372 }
30373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30374         LDKChannelDetails arg_conv;
30375         arg_conv.inner = (void*)(arg & (~1));
30376         arg_conv.is_owned = false;
30377         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30378         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
30379         return ret_conv;
30380 }
30381
30382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30383         LDKChannelDetails orig_conv;
30384         orig_conv.inner = (void*)(orig & (~1));
30385         orig_conv.is_owned = false;
30386         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30387         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
30388         int64_t ret_ref = 0;
30389         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30390         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30392         ret_ref = (uintptr_t)ret_var.inner;
30393         if (ret_var.is_owned) {
30394                 ret_ref |= 1;
30395         }
30396         return ret_ref;
30397 }
30398
30399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
30400         LDKChannelDetails this_arg_conv;
30401         this_arg_conv.inner = (void*)(this_arg & (~1));
30402         this_arg_conv.is_owned = false;
30403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30404         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30405         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
30406         int64_t ret_ref = (uintptr_t)ret_copy;
30407         return ret_ref;
30408 }
30409
30410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
30411         LDKChannelDetails this_arg_conv;
30412         this_arg_conv.inner = (void*)(this_arg & (~1));
30413         this_arg_conv.is_owned = false;
30414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30415         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30416         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
30417         int64_t ret_ref = (uintptr_t)ret_copy;
30418         return ret_ref;
30419 }
30420
30421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30422         if ((this_ptr & 1) != 0) return;
30423         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
30424         CHECK_ACCESS(this_ptr_ptr);
30425         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
30426         FREE((void*)this_ptr);
30427         PaymentSendFailure_free(this_ptr_conv);
30428 }
30429
30430 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
30431         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30432         *ret_copy = PaymentSendFailure_clone(arg);
30433 int64_t ret_ref = (uintptr_t)ret_copy;
30434         return ret_ref;
30435 }
30436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30437         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
30438         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
30439         return ret_conv;
30440 }
30441
30442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30443         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
30444         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30445         *ret_copy = PaymentSendFailure_clone(orig_conv);
30446         int64_t ret_ref = (uintptr_t)ret_copy;
30447         return ret_ref;
30448 }
30449
30450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
30451         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
30452         CHECK_ACCESS(a_ptr);
30453         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
30454         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
30455         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30456         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
30457         int64_t ret_ref = (uintptr_t)ret_copy;
30458         return ret_ref;
30459 }
30460
30461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
30462         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
30463         a_constr.datalen = (*env)->GetArrayLength(env, a);
30464         if (a_constr.datalen > 0)
30465                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
30466         else
30467                 a_constr.data = NULL;
30468         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
30469         for (size_t w = 0; w < a_constr.datalen; w++) {
30470                 int64_t a_conv_22 = a_vals[w];
30471                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
30472                 CHECK_ACCESS(a_conv_22_ptr);
30473                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
30474                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
30475                 a_constr.data[w] = a_conv_22_conv;
30476         }
30477         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
30478         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30479         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
30480         int64_t ret_ref = (uintptr_t)ret_copy;
30481         return ret_ref;
30482 }
30483
30484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
30485         LDKCVec_APIErrorZ a_constr;
30486         a_constr.datalen = (*env)->GetArrayLength(env, a);
30487         if (a_constr.datalen > 0)
30488                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
30489         else
30490                 a_constr.data = NULL;
30491         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
30492         for (size_t k = 0; k < a_constr.datalen; k++) {
30493                 int64_t a_conv_10 = a_vals[k];
30494                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
30495                 CHECK_ACCESS(a_conv_10_ptr);
30496                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
30497                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
30498                 a_constr.data[k] = a_conv_10_conv;
30499         }
30500         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
30501         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30502         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
30503         int64_t ret_ref = (uintptr_t)ret_copy;
30504         return ret_ref;
30505 }
30506
30507 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) {
30508         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
30509         results_constr.datalen = (*env)->GetArrayLength(env, results);
30510         if (results_constr.datalen > 0)
30511                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
30512         else
30513                 results_constr.data = NULL;
30514         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
30515         for (size_t w = 0; w < results_constr.datalen; w++) {
30516                 int64_t results_conv_22 = results_vals[w];
30517                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
30518                 CHECK_ACCESS(results_conv_22_ptr);
30519                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
30520                 results_constr.data[w] = results_conv_22_conv;
30521         }
30522         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
30523         LDKRouteParameters failed_paths_retry_conv;
30524         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
30525         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
30526         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
30527         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
30528         LDKThirtyTwoBytes payment_id_ref;
30529         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
30530         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
30531         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30532         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
30533         int64_t ret_ref = (uintptr_t)ret_copy;
30534         return ret_ref;
30535 }
30536
30537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30538         LDKPhantomRouteHints this_obj_conv;
30539         this_obj_conv.inner = (void*)(this_obj & (~1));
30540         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30542         PhantomRouteHints_free(this_obj_conv);
30543 }
30544
30545 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
30546         LDKPhantomRouteHints this_ptr_conv;
30547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30548         this_ptr_conv.is_owned = false;
30549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30550         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
30551         int64_tArray ret_arr = NULL;
30552         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30553         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30554         for (size_t q = 0; q < ret_var.datalen; q++) {
30555                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
30556                 int64_t ret_conv_16_ref = 0;
30557                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30558                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30559                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30560                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30561                 if (ret_conv_16_var.is_owned) {
30562                         ret_conv_16_ref |= 1;
30563                 }
30564                 ret_arr_ptr[q] = ret_conv_16_ref;
30565         }
30566         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30567         FREE(ret_var.data);
30568         return ret_arr;
30569 }
30570
30571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
30572         LDKPhantomRouteHints this_ptr_conv;
30573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30574         this_ptr_conv.is_owned = false;
30575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30576         LDKCVec_ChannelDetailsZ val_constr;
30577         val_constr.datalen = (*env)->GetArrayLength(env, val);
30578         if (val_constr.datalen > 0)
30579                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
30580         else
30581                 val_constr.data = NULL;
30582         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
30583         for (size_t q = 0; q < val_constr.datalen; q++) {
30584                 int64_t val_conv_16 = val_vals[q];
30585                 LDKChannelDetails val_conv_16_conv;
30586                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
30587                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
30588                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
30589                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
30590                 val_constr.data[q] = val_conv_16_conv;
30591         }
30592         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
30593         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
30594 }
30595
30596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
30597         LDKPhantomRouteHints this_ptr_conv;
30598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30599         this_ptr_conv.is_owned = false;
30600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30601         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
30602         return ret_conv;
30603 }
30604
30605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30606         LDKPhantomRouteHints this_ptr_conv;
30607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30608         this_ptr_conv.is_owned = false;
30609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30610         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
30611 }
30612
30613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30614         LDKPhantomRouteHints this_ptr_conv;
30615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30616         this_ptr_conv.is_owned = false;
30617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30618         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30619         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
30620         return ret_arr;
30621 }
30622
30623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30624         LDKPhantomRouteHints this_ptr_conv;
30625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30626         this_ptr_conv.is_owned = false;
30627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30628         LDKPublicKey val_ref;
30629         CHECK((*env)->GetArrayLength(env, val) == 33);
30630         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30631         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
30632 }
30633
30634 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) {
30635         LDKCVec_ChannelDetailsZ channels_arg_constr;
30636         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
30637         if (channels_arg_constr.datalen > 0)
30638                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
30639         else
30640                 channels_arg_constr.data = NULL;
30641         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
30642         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
30643                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
30644                 LDKChannelDetails channels_arg_conv_16_conv;
30645                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
30646                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
30647                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
30648                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
30649                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
30650         }
30651         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
30652         LDKPublicKey real_node_pubkey_arg_ref;
30653         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
30654         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
30655         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
30656         int64_t ret_ref = 0;
30657         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30658         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30660         ret_ref = (uintptr_t)ret_var.inner;
30661         if (ret_var.is_owned) {
30662                 ret_ref |= 1;
30663         }
30664         return ret_ref;
30665 }
30666
30667 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
30668         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
30669 int64_t ret_ref = 0;
30670 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30671 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30672 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30673 ret_ref = (uintptr_t)ret_var.inner;
30674 if (ret_var.is_owned) {
30675         ret_ref |= 1;
30676 }
30677         return ret_ref;
30678 }
30679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30680         LDKPhantomRouteHints arg_conv;
30681         arg_conv.inner = (void*)(arg & (~1));
30682         arg_conv.is_owned = false;
30683         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30684         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
30685         return ret_conv;
30686 }
30687
30688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30689         LDKPhantomRouteHints orig_conv;
30690         orig_conv.inner = (void*)(orig & (~1));
30691         orig_conv.is_owned = false;
30692         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30693         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
30694         int64_t ret_ref = 0;
30695         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30696         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30698         ret_ref = (uintptr_t)ret_var.inner;
30699         if (ret_var.is_owned) {
30700                 ret_ref |= 1;
30701         }
30702         return ret_ref;
30703 }
30704
30705 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) {
30706         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
30707         CHECK_ACCESS(fee_est_ptr);
30708         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
30709         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
30710                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30711                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
30712         }
30713         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
30714         CHECK_ACCESS(chain_monitor_ptr);
30715         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
30716         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
30717                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30718                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
30719         }
30720         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
30721         CHECK_ACCESS(tx_broadcaster_ptr);
30722         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
30723         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30724                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30725                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
30726         }
30727         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
30728         CHECK_ACCESS(logger_ptr);
30729         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30730         if (logger_conv.free == LDKLogger_JCalls_free) {
30731                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30732                 LDKLogger_JCalls_cloned(&logger_conv);
30733         }
30734         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
30735         CHECK_ACCESS(keys_manager_ptr);
30736         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
30737         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
30738                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30739                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
30740         }
30741         LDKUserConfig config_conv;
30742         config_conv.inner = (void*)(config & (~1));
30743         config_conv.is_owned = (config & 1) || (config == 0);
30744         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
30745         config_conv = UserConfig_clone(&config_conv);
30746         LDKChainParameters params_conv;
30747         params_conv.inner = (void*)(params & (~1));
30748         params_conv.is_owned = (params & 1) || (params == 0);
30749         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
30750         params_conv = ChainParameters_clone(&params_conv);
30751         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
30752         int64_t ret_ref = 0;
30753         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30754         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30756         ret_ref = (uintptr_t)ret_var.inner;
30757         if (ret_var.is_owned) {
30758                 ret_ref |= 1;
30759         }
30760         return ret_ref;
30761 }
30762
30763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
30764         LDKChannelManager this_arg_conv;
30765         this_arg_conv.inner = (void*)(this_arg & (~1));
30766         this_arg_conv.is_owned = false;
30767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30768         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
30769         int64_t ret_ref = 0;
30770         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30771         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30773         ret_ref = (uintptr_t)ret_var.inner;
30774         if (ret_var.is_owned) {
30775                 ret_ref |= 1;
30776         }
30777         return ret_ref;
30778 }
30779
30780 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) {
30781         LDKChannelManager this_arg_conv;
30782         this_arg_conv.inner = (void*)(this_arg & (~1));
30783         this_arg_conv.is_owned = false;
30784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30785         LDKPublicKey their_network_key_ref;
30786         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
30787         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
30788         LDKUserConfig override_config_conv;
30789         override_config_conv.inner = (void*)(override_config & (~1));
30790         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
30791         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
30792         override_config_conv = UserConfig_clone(&override_config_conv);
30793         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
30794         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
30795         return (int64_t)ret_conv;
30796 }
30797
30798 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
30799         LDKChannelManager this_arg_conv;
30800         this_arg_conv.inner = (void*)(this_arg & (~1));
30801         this_arg_conv.is_owned = false;
30802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30803         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
30804         int64_tArray ret_arr = NULL;
30805         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30806         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30807         for (size_t q = 0; q < ret_var.datalen; q++) {
30808                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
30809                 int64_t ret_conv_16_ref = 0;
30810                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30811                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30812                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30813                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30814                 if (ret_conv_16_var.is_owned) {
30815                         ret_conv_16_ref |= 1;
30816                 }
30817                 ret_arr_ptr[q] = ret_conv_16_ref;
30818         }
30819         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30820         FREE(ret_var.data);
30821         return ret_arr;
30822 }
30823
30824 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
30825         LDKChannelManager this_arg_conv;
30826         this_arg_conv.inner = (void*)(this_arg & (~1));
30827         this_arg_conv.is_owned = false;
30828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30829         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
30830         int64_tArray ret_arr = NULL;
30831         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30832         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30833         for (size_t q = 0; q < ret_var.datalen; q++) {
30834                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
30835                 int64_t ret_conv_16_ref = 0;
30836                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30837                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30838                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30839                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30840                 if (ret_conv_16_var.is_owned) {
30841                         ret_conv_16_ref |= 1;
30842                 }
30843                 ret_arr_ptr[q] = ret_conv_16_ref;
30844         }
30845         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30846         FREE(ret_var.data);
30847         return ret_arr;
30848 }
30849
30850 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) {
30851         LDKChannelManager this_arg_conv;
30852         this_arg_conv.inner = (void*)(this_arg & (~1));
30853         this_arg_conv.is_owned = false;
30854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30855         unsigned char channel_id_arr[32];
30856         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30857         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30858         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30859         LDKPublicKey counterparty_node_id_ref;
30860         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30861         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30862         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30863         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
30864         return (int64_t)ret_conv;
30865 }
30866
30867 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) {
30868         LDKChannelManager this_arg_conv;
30869         this_arg_conv.inner = (void*)(this_arg & (~1));
30870         this_arg_conv.is_owned = false;
30871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30872         unsigned char channel_id_arr[32];
30873         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30874         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30875         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30876         LDKPublicKey counterparty_node_id_ref;
30877         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30878         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30879         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30880         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
30881         return (int64_t)ret_conv;
30882 }
30883
30884 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) {
30885         LDKChannelManager this_arg_conv;
30886         this_arg_conv.inner = (void*)(this_arg & (~1));
30887         this_arg_conv.is_owned = false;
30888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30889         unsigned char channel_id_arr[32];
30890         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30891         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30892         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30893         LDKPublicKey counterparty_node_id_ref;
30894         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30895         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30896         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30897         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
30898         return (int64_t)ret_conv;
30899 }
30900
30901 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) {
30902         LDKChannelManager this_arg_conv;
30903         this_arg_conv.inner = (void*)(this_arg & (~1));
30904         this_arg_conv.is_owned = false;
30905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30906         unsigned char channel_id_arr[32];
30907         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30908         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30909         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30910         LDKPublicKey counterparty_node_id_ref;
30911         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30912         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30913         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30914         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
30915         return (int64_t)ret_conv;
30916 }
30917
30918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
30919         LDKChannelManager this_arg_conv;
30920         this_arg_conv.inner = (void*)(this_arg & (~1));
30921         this_arg_conv.is_owned = false;
30922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30923         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
30924 }
30925
30926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
30927         LDKChannelManager this_arg_conv;
30928         this_arg_conv.inner = (void*)(this_arg & (~1));
30929         this_arg_conv.is_owned = false;
30930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30931         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
30932 }
30933
30934 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) {
30935         LDKChannelManager this_arg_conv;
30936         this_arg_conv.inner = (void*)(this_arg & (~1));
30937         this_arg_conv.is_owned = false;
30938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30939         LDKRoute route_conv;
30940         route_conv.inner = (void*)(route & (~1));
30941         route_conv.is_owned = false;
30942         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
30943         LDKThirtyTwoBytes payment_hash_ref;
30944         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30945         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
30946         LDKThirtyTwoBytes payment_secret_ref;
30947         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
30948         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
30949         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
30950         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
30951         return (int64_t)ret_conv;
30952 }
30953
30954 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) {
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_id_ref;
30964         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
30965         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
30966         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
30967         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
30968         return (int64_t)ret_conv;
30969 }
30970
30971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
30972         LDKChannelManager this_arg_conv;
30973         this_arg_conv.inner = (void*)(this_arg & (~1));
30974         this_arg_conv.is_owned = false;
30975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30976         LDKThirtyTwoBytes payment_id_ref;
30977         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
30978         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
30979         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
30980 }
30981
30982 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) {
30983         LDKChannelManager this_arg_conv;
30984         this_arg_conv.inner = (void*)(this_arg & (~1));
30985         this_arg_conv.is_owned = false;
30986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30987         LDKRoute route_conv;
30988         route_conv.inner = (void*)(route & (~1));
30989         route_conv.is_owned = false;
30990         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
30991         LDKThirtyTwoBytes payment_preimage_ref;
30992         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
30993         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
30994         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
30995         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
30996         return (int64_t)ret_conv;
30997 }
30998
30999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1probe(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray hops) {
31000         LDKChannelManager this_arg_conv;
31001         this_arg_conv.inner = (void*)(this_arg & (~1));
31002         this_arg_conv.is_owned = false;
31003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31004         LDKCVec_RouteHopZ hops_constr;
31005         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
31006         if (hops_constr.datalen > 0)
31007                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
31008         else
31009                 hops_constr.data = NULL;
31010         int64_t* hops_vals = (*env)->GetLongArrayElements (env, hops, NULL);
31011         for (size_t k = 0; k < hops_constr.datalen; k++) {
31012                 int64_t hops_conv_10 = hops_vals[k];
31013                 LDKRouteHop hops_conv_10_conv;
31014                 hops_conv_10_conv.inner = (void*)(hops_conv_10 & (~1));
31015                 hops_conv_10_conv.is_owned = (hops_conv_10 & 1) || (hops_conv_10 == 0);
31016                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv_10_conv);
31017                 hops_conv_10_conv = RouteHop_clone(&hops_conv_10_conv);
31018                 hops_constr.data[k] = hops_conv_10_conv;
31019         }
31020         (*env)->ReleaseLongArrayElements(env, hops, hops_vals, 0);
31021         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
31022         *ret_conv = ChannelManager_send_probe(&this_arg_conv, hops_constr);
31023         return (int64_t)ret_conv;
31024 }
31025
31026 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) {
31027         LDKChannelManager this_arg_conv;
31028         this_arg_conv.inner = (void*)(this_arg & (~1));
31029         this_arg_conv.is_owned = false;
31030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31031         unsigned char temporary_channel_id_arr[32];
31032         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
31033         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
31034         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
31035         LDKPublicKey counterparty_node_id_ref;
31036         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31037         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31038         LDKTransaction funding_transaction_ref;
31039         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
31040         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
31041         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
31042         funding_transaction_ref.data_is_owned = true;
31043         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31044         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
31045         return (int64_t)ret_conv;
31046 }
31047
31048 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) {
31049         LDKChannelManager this_arg_conv;
31050         this_arg_conv.inner = (void*)(this_arg & (~1));
31051         this_arg_conv.is_owned = false;
31052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31053         LDKThreeBytes rgb_ref;
31054         CHECK((*env)->GetArrayLength(env, rgb) == 3);
31055         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
31056         LDKThirtyTwoBytes alias_ref;
31057         CHECK((*env)->GetArrayLength(env, alias) == 32);
31058         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
31059         LDKCVec_NetAddressZ addresses_constr;
31060         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
31061         if (addresses_constr.datalen > 0)
31062                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
31063         else
31064                 addresses_constr.data = NULL;
31065         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
31066         for (size_t m = 0; m < addresses_constr.datalen; m++) {
31067                 int64_t addresses_conv_12 = addresses_vals[m];
31068                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
31069                 CHECK_ACCESS(addresses_conv_12_ptr);
31070                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
31071                 addresses_constr.data[m] = addresses_conv_12_conv;
31072         }
31073         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
31074         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
31075 }
31076
31077 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) {
31078         LDKChannelManager this_arg_conv;
31079         this_arg_conv.inner = (void*)(this_arg & (~1));
31080         this_arg_conv.is_owned = false;
31081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31082         LDKPublicKey counterparty_node_id_ref;
31083         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31084         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31085         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
31086         channel_ids_constr.datalen = (*env)->GetArrayLength(env, channel_ids);
31087         if (channel_ids_constr.datalen > 0)
31088                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
31089         else
31090                 channel_ids_constr.data = NULL;
31091         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
31092                 int8_tArray channel_ids_conv_8 = (*env)->GetObjectArrayElement(env, channel_ids, i);
31093                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
31094                 CHECK((*env)->GetArrayLength(env, channel_ids_conv_8) == 32);
31095                 (*env)->GetByteArrayRegion(env, channel_ids_conv_8, 0, 32, channel_ids_conv_8_ref.data);
31096                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
31097         }
31098         LDKChannelConfig config_conv;
31099         config_conv.inner = (void*)(config & (~1));
31100         config_conv.is_owned = false;
31101         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
31102         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31103         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
31104         return (int64_t)ret_conv;
31105 }
31106
31107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
31108         LDKChannelManager this_arg_conv;
31109         this_arg_conv.inner = (void*)(this_arg & (~1));
31110         this_arg_conv.is_owned = false;
31111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31112         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
31113 }
31114
31115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
31116         LDKChannelManager this_arg_conv;
31117         this_arg_conv.inner = (void*)(this_arg & (~1));
31118         this_arg_conv.is_owned = false;
31119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31120         ChannelManager_timer_tick_occurred(&this_arg_conv);
31121 }
31122
31123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
31124         LDKChannelManager this_arg_conv;
31125         this_arg_conv.inner = (void*)(this_arg & (~1));
31126         this_arg_conv.is_owned = false;
31127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31128         unsigned char payment_hash_arr[32];
31129         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31130         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
31131         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
31132         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
31133 }
31134
31135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
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         LDKThirtyTwoBytes payment_preimage_ref;
31141         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
31142         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
31143         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
31144 }
31145
31146 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
31147         LDKChannelManager this_arg_conv;
31148         this_arg_conv.inner = (void*)(this_arg & (~1));
31149         this_arg_conv.is_owned = false;
31150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31151         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31152         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
31153         return ret_arr;
31154 }
31155
31156 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) {
31157         LDKChannelManager this_arg_conv;
31158         this_arg_conv.inner = (void*)(this_arg & (~1));
31159         this_arg_conv.is_owned = false;
31160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31161         unsigned char temporary_channel_id_arr[32];
31162         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
31163         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
31164         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
31165         LDKPublicKey counterparty_node_id_ref;
31166         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31167         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31168         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31169         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
31170         return (int64_t)ret_conv;
31171 }
31172
31173 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) {
31174         LDKChannelManager this_arg_conv;
31175         this_arg_conv.inner = (void*)(this_arg & (~1));
31176         this_arg_conv.is_owned = false;
31177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31178         unsigned char temporary_channel_id_arr[32];
31179         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
31180         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
31181         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
31182         LDKPublicKey counterparty_node_id_ref;
31183         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31184         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31185         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31186         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
31187         return (int64_t)ret_conv;
31188 }
31189
31190 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) {
31191         LDKChannelManager this_arg_conv;
31192         this_arg_conv.inner = (void*)(this_arg & (~1));
31193         this_arg_conv.is_owned = false;
31194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31195         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31196         CHECK_ACCESS(min_value_msat_ptr);
31197         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31198         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31199         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
31200         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
31201         return (int64_t)ret_conv;
31202 }
31203
31204 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) {
31205         LDKChannelManager this_arg_conv;
31206         this_arg_conv.inner = (void*)(this_arg & (~1));
31207         this_arg_conv.is_owned = false;
31208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31209         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31210         CHECK_ACCESS(min_value_msat_ptr);
31211         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31212         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31213         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
31214         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
31215         return (int64_t)ret_conv;
31216 }
31217
31218 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) {
31219         LDKChannelManager this_arg_conv;
31220         this_arg_conv.inner = (void*)(this_arg & (~1));
31221         this_arg_conv.is_owned = false;
31222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31223         LDKThirtyTwoBytes payment_hash_ref;
31224         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31225         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31226         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31227         CHECK_ACCESS(min_value_msat_ptr);
31228         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31229         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31230         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
31231         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
31232         return (int64_t)ret_conv;
31233 }
31234
31235 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) {
31236         LDKChannelManager this_arg_conv;
31237         this_arg_conv.inner = (void*)(this_arg & (~1));
31238         this_arg_conv.is_owned = false;
31239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31240         LDKThirtyTwoBytes payment_hash_ref;
31241         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31242         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31243         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31244         CHECK_ACCESS(min_value_msat_ptr);
31245         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31246         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31247         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
31248         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
31249         return (int64_t)ret_conv;
31250 }
31251
31252 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) {
31253         LDKChannelManager this_arg_conv;
31254         this_arg_conv.inner = (void*)(this_arg & (~1));
31255         this_arg_conv.is_owned = false;
31256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31257         LDKThirtyTwoBytes payment_hash_ref;
31258         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31259         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31260         LDKThirtyTwoBytes payment_secret_ref;
31261         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
31262         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
31263         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
31264         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
31265         return (int64_t)ret_conv;
31266 }
31267
31268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
31269         LDKChannelManager this_arg_conv;
31270         this_arg_conv.inner = (void*)(this_arg & (~1));
31271         this_arg_conv.is_owned = false;
31272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31273         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
31274         return ret_conv;
31275 }
31276
31277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
31278         LDKChannelManager this_arg_conv;
31279         this_arg_conv.inner = (void*)(this_arg & (~1));
31280         this_arg_conv.is_owned = false;
31281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31282         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
31283         int64_t ret_ref = 0;
31284         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31285         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31287         ret_ref = (uintptr_t)ret_var.inner;
31288         if (ret_var.is_owned) {
31289                 ret_ref |= 1;
31290         }
31291         return ret_ref;
31292 }
31293
31294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31295         LDKChannelManager this_arg_conv;
31296         this_arg_conv.inner = (void*)(this_arg & (~1));
31297         this_arg_conv.is_owned = false;
31298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31299         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
31300         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
31301         return (int64_t)ret_ret;
31302 }
31303
31304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31305         LDKChannelManager this_arg_conv;
31306         this_arg_conv.inner = (void*)(this_arg & (~1));
31307         this_arg_conv.is_owned = false;
31308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31309         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
31310         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
31311         return (int64_t)ret_ret;
31312 }
31313
31314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(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         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
31320         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
31321         return (int64_t)ret_ret;
31322 }
31323
31324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(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         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
31330         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
31331         return (int64_t)ret_ret;
31332 }
31333
31334 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) {
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         jboolean ret_conv = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
31340         return ret_conv;
31341 }
31342
31343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
31344         LDKChannelManager this_arg_conv;
31345         this_arg_conv.inner = (void*)(this_arg & (~1));
31346         this_arg_conv.is_owned = false;
31347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31348         ChannelManager_await_persistable_update(&this_arg_conv);
31349 }
31350
31351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
31352         LDKChannelManager this_arg_conv;
31353         this_arg_conv.inner = (void*)(this_arg & (~1));
31354         this_arg_conv.is_owned = false;
31355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31356         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
31357         int64_t ret_ref = 0;
31358         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31359         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31361         ret_ref = (uintptr_t)ret_var.inner;
31362         if (ret_var.is_owned) {
31363                 ret_ref |= 1;
31364         }
31365         return ret_ref;
31366 }
31367
31368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
31369         LDKChannelManager this_arg_conv;
31370         this_arg_conv.inner = (void*)(this_arg & (~1));
31371         this_arg_conv.is_owned = false;
31372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31373         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
31374         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
31375         return (int64_t)ret_ret;
31376 }
31377
31378 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
31379         LDKCounterpartyForwardingInfo obj_conv;
31380         obj_conv.inner = (void*)(obj & (~1));
31381         obj_conv.is_owned = false;
31382         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31383         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
31384         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31385         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31386         CVec_u8Z_free(ret_var);
31387         return ret_arr;
31388 }
31389
31390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31391         LDKu8slice ser_ref;
31392         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31393         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31394         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
31395         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
31396         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31397         return (int64_t)ret_conv;
31398 }
31399
31400 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
31401         LDKChannelCounterparty obj_conv;
31402         obj_conv.inner = (void*)(obj & (~1));
31403         obj_conv.is_owned = false;
31404         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31405         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
31406         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31407         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31408         CVec_u8Z_free(ret_var);
31409         return ret_arr;
31410 }
31411
31412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31413         LDKu8slice ser_ref;
31414         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31415         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31416         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
31417         *ret_conv = ChannelCounterparty_read(ser_ref);
31418         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31419         return (int64_t)ret_conv;
31420 }
31421
31422 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
31423         LDKChannelDetails obj_conv;
31424         obj_conv.inner = (void*)(obj & (~1));
31425         obj_conv.is_owned = false;
31426         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31427         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
31428         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31429         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31430         CVec_u8Z_free(ret_var);
31431         return ret_arr;
31432 }
31433
31434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31435         LDKu8slice ser_ref;
31436         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31437         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31438         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
31439         *ret_conv = ChannelDetails_read(ser_ref);
31440         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31441         return (int64_t)ret_conv;
31442 }
31443
31444 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
31445         LDKPhantomRouteHints obj_conv;
31446         obj_conv.inner = (void*)(obj & (~1));
31447         obj_conv.is_owned = false;
31448         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31449         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
31450         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31451         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31452         CVec_u8Z_free(ret_var);
31453         return ret_arr;
31454 }
31455
31456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31457         LDKu8slice ser_ref;
31458         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31459         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31460         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
31461         *ret_conv = PhantomRouteHints_read(ser_ref);
31462         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31463         return (int64_t)ret_conv;
31464 }
31465
31466 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
31467         LDKChannelManager obj_conv;
31468         obj_conv.inner = (void*)(obj & (~1));
31469         obj_conv.is_owned = false;
31470         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31471         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
31472         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31473         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31474         CVec_u8Z_free(ret_var);
31475         return ret_arr;
31476 }
31477
31478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31479         LDKChannelManagerReadArgs this_obj_conv;
31480         this_obj_conv.inner = (void*)(this_obj & (~1));
31481         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31483         ChannelManagerReadArgs_free(this_obj_conv);
31484 }
31485
31486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
31487         LDKChannelManagerReadArgs this_ptr_conv;
31488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31489         this_ptr_conv.is_owned = false;
31490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31491         // WARNING: This object doesn't live past this scope, needs clone!
31492         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
31493         return ret_ret;
31494 }
31495
31496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31497         LDKChannelManagerReadArgs this_ptr_conv;
31498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31499         this_ptr_conv.is_owned = false;
31500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31501         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31502         CHECK_ACCESS(val_ptr);
31503         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
31504         if (val_conv.free == LDKKeysInterface_JCalls_free) {
31505                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31506                 LDKKeysInterface_JCalls_cloned(&val_conv);
31507         }
31508         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
31509 }
31510
31511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
31512         LDKChannelManagerReadArgs this_ptr_conv;
31513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31514         this_ptr_conv.is_owned = false;
31515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31516         // WARNING: This object doesn't live past this scope, needs clone!
31517         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
31518         return ret_ret;
31519 }
31520
31521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31522         LDKChannelManagerReadArgs this_ptr_conv;
31523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31524         this_ptr_conv.is_owned = false;
31525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31526         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31527         CHECK_ACCESS(val_ptr);
31528         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
31529         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
31530                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31531                 LDKFeeEstimator_JCalls_cloned(&val_conv);
31532         }
31533         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
31534 }
31535
31536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
31537         LDKChannelManagerReadArgs this_ptr_conv;
31538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31539         this_ptr_conv.is_owned = false;
31540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31541         // WARNING: This object doesn't live past this scope, needs clone!
31542         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
31543         return ret_ret;
31544 }
31545
31546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31547         LDKChannelManagerReadArgs this_ptr_conv;
31548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31549         this_ptr_conv.is_owned = false;
31550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31551         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31552         CHECK_ACCESS(val_ptr);
31553         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
31554         if (val_conv.free == LDKWatch_JCalls_free) {
31555                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31556                 LDKWatch_JCalls_cloned(&val_conv);
31557         }
31558         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
31559 }
31560
31561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
31562         LDKChannelManagerReadArgs this_ptr_conv;
31563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31564         this_ptr_conv.is_owned = false;
31565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31566         // WARNING: This object doesn't live past this scope, needs clone!
31567         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
31568         return ret_ret;
31569 }
31570
31571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31572         LDKChannelManagerReadArgs this_ptr_conv;
31573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31574         this_ptr_conv.is_owned = false;
31575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31576         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31577         CHECK_ACCESS(val_ptr);
31578         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
31579         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
31580                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31581                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
31582         }
31583         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
31584 }
31585
31586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
31587         LDKChannelManagerReadArgs this_ptr_conv;
31588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31589         this_ptr_conv.is_owned = false;
31590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31591         // WARNING: This object doesn't live past this scope, needs clone!
31592         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
31593         return ret_ret;
31594 }
31595
31596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31597         LDKChannelManagerReadArgs this_ptr_conv;
31598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31599         this_ptr_conv.is_owned = false;
31600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31601         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31602         CHECK_ACCESS(val_ptr);
31603         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
31604         if (val_conv.free == LDKLogger_JCalls_free) {
31605                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31606                 LDKLogger_JCalls_cloned(&val_conv);
31607         }
31608         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
31609 }
31610
31611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
31612         LDKChannelManagerReadArgs this_ptr_conv;
31613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31614         this_ptr_conv.is_owned = false;
31615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31616         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
31617         int64_t ret_ref = 0;
31618         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31619         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31621         ret_ref = (uintptr_t)ret_var.inner;
31622         if (ret_var.is_owned) {
31623                 ret_ref |= 1;
31624         }
31625         return ret_ref;
31626 }
31627
31628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31629         LDKChannelManagerReadArgs this_ptr_conv;
31630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31631         this_ptr_conv.is_owned = false;
31632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31633         LDKUserConfig val_conv;
31634         val_conv.inner = (void*)(val & (~1));
31635         val_conv.is_owned = (val & 1) || (val == 0);
31636         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31637         val_conv = UserConfig_clone(&val_conv);
31638         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
31639 }
31640
31641 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) {
31642         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
31643         CHECK_ACCESS(keys_manager_ptr);
31644         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
31645         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
31646                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31647                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
31648         }
31649         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
31650         CHECK_ACCESS(fee_estimator_ptr);
31651         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
31652         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
31653                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31654                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
31655         }
31656         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
31657         CHECK_ACCESS(chain_monitor_ptr);
31658         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
31659         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
31660                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31661                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
31662         }
31663         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
31664         CHECK_ACCESS(tx_broadcaster_ptr);
31665         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
31666         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
31667                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31668                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
31669         }
31670         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
31671         CHECK_ACCESS(logger_ptr);
31672         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
31673         if (logger_conv.free == LDKLogger_JCalls_free) {
31674                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31675                 LDKLogger_JCalls_cloned(&logger_conv);
31676         }
31677         LDKUserConfig default_config_conv;
31678         default_config_conv.inner = (void*)(default_config & (~1));
31679         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
31680         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
31681         default_config_conv = UserConfig_clone(&default_config_conv);
31682         LDKCVec_ChannelMonitorZ channel_monitors_constr;
31683         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
31684         if (channel_monitors_constr.datalen > 0)
31685                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
31686         else
31687                 channel_monitors_constr.data = NULL;
31688         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
31689         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
31690                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
31691                 LDKChannelMonitor channel_monitors_conv_16_conv;
31692                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
31693                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
31694                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
31695                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
31696         }
31697         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
31698         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);
31699         int64_t ret_ref = 0;
31700         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31701         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31703         ret_ref = (uintptr_t)ret_var.inner;
31704         if (ret_var.is_owned) {
31705                 ret_ref |= 1;
31706         }
31707         return ret_ref;
31708 }
31709
31710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
31711         LDKu8slice ser_ref;
31712         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31713         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31714         LDKChannelManagerReadArgs arg_conv;
31715         arg_conv.inner = (void*)(arg & (~1));
31716         arg_conv.is_owned = (arg & 1) || (arg == 0);
31717         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31718         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
31719         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
31720         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
31721         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31722         return (int64_t)ret_conv;
31723 }
31724
31725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31726         LDKExpandedKey this_obj_conv;
31727         this_obj_conv.inner = (void*)(this_obj & (~1));
31728         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31730         ExpandedKey_free(this_obj_conv);
31731 }
31732
31733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1new(JNIEnv *env, jclass clz, int8_tArray key_material) {
31734         unsigned char key_material_arr[32];
31735         CHECK((*env)->GetArrayLength(env, key_material) == 32);
31736         (*env)->GetByteArrayRegion(env, key_material, 0, 32, key_material_arr);
31737         unsigned char (*key_material_ref)[32] = &key_material_arr;
31738         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
31739         int64_t ret_ref = 0;
31740         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31741         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31743         ret_ref = (uintptr_t)ret_var.inner;
31744         if (ret_var.is_owned) {
31745                 ret_ref |= 1;
31746         }
31747         return ret_ref;
31748 }
31749
31750 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) {
31751         LDKExpandedKey keys_conv;
31752         keys_conv.inner = (void*)(keys & (~1));
31753         keys_conv.is_owned = false;
31754         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
31755         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31756         CHECK_ACCESS(min_value_msat_ptr);
31757         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31758         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31759         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
31760         if (!(keys_manager & 1)) { CHECK_ACCESS(keys_manager_ptr); }
31761         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
31762         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
31763         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
31764         return (int64_t)ret_conv;
31765 }
31766
31767 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) {
31768         LDKExpandedKey keys_conv;
31769         keys_conv.inner = (void*)(keys & (~1));
31770         keys_conv.is_owned = false;
31771         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
31772         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31773         CHECK_ACCESS(min_value_msat_ptr);
31774         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31775         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31776         LDKThirtyTwoBytes payment_hash_ref;
31777         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31778         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31779         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
31780         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
31781         return (int64_t)ret_conv;
31782 }
31783
31784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31785         LDKDecodeError this_obj_conv;
31786         this_obj_conv.inner = (void*)(this_obj & (~1));
31787         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31789         DecodeError_free(this_obj_conv);
31790 }
31791
31792 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
31793         LDKDecodeError ret_var = DecodeError_clone(arg);
31794 int64_t ret_ref = 0;
31795 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31796 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31797 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31798 ret_ref = (uintptr_t)ret_var.inner;
31799 if (ret_var.is_owned) {
31800         ret_ref |= 1;
31801 }
31802         return ret_ref;
31803 }
31804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31805         LDKDecodeError arg_conv;
31806         arg_conv.inner = (void*)(arg & (~1));
31807         arg_conv.is_owned = false;
31808         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31809         int64_t ret_conv = DecodeError_clone_ptr(&arg_conv);
31810         return ret_conv;
31811 }
31812
31813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31814         LDKDecodeError orig_conv;
31815         orig_conv.inner = (void*)(orig & (~1));
31816         orig_conv.is_owned = false;
31817         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31818         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
31819         int64_t ret_ref = 0;
31820         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31821         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31823         ret_ref = (uintptr_t)ret_var.inner;
31824         if (ret_var.is_owned) {
31825                 ret_ref |= 1;
31826         }
31827         return ret_ref;
31828 }
31829
31830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31831         LDKInit this_obj_conv;
31832         this_obj_conv.inner = (void*)(this_obj & (~1));
31833         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31835         Init_free(this_obj_conv);
31836 }
31837
31838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
31839         LDKInit this_ptr_conv;
31840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31841         this_ptr_conv.is_owned = false;
31842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31843         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
31844         int64_t ret_ref = 0;
31845         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31846         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31847         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31848         ret_ref = (uintptr_t)ret_var.inner;
31849         if (ret_var.is_owned) {
31850                 ret_ref |= 1;
31851         }
31852         return ret_ref;
31853 }
31854
31855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31856         LDKInit this_ptr_conv;
31857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31858         this_ptr_conv.is_owned = false;
31859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31860         LDKInitFeatures val_conv;
31861         val_conv.inner = (void*)(val & (~1));
31862         val_conv.is_owned = (val & 1) || (val == 0);
31863         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31864         val_conv = InitFeatures_clone(&val_conv);
31865         Init_set_features(&this_ptr_conv, val_conv);
31866 }
31867
31868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
31869         LDKInit this_ptr_conv;
31870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31871         this_ptr_conv.is_owned = false;
31872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31873         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
31874         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
31875         int64_t ret_ref = (uintptr_t)ret_copy;
31876         return ret_ref;
31877 }
31878
31879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31880         LDKInit this_ptr_conv;
31881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31882         this_ptr_conv.is_owned = false;
31883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31884         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31885         CHECK_ACCESS(val_ptr);
31886         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
31887         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
31888         Init_set_remote_network_address(&this_ptr_conv, val_conv);
31889 }
31890
31891 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) {
31892         LDKInitFeatures features_arg_conv;
31893         features_arg_conv.inner = (void*)(features_arg & (~1));
31894         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
31895         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
31896         features_arg_conv = InitFeatures_clone(&features_arg_conv);
31897         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
31898         CHECK_ACCESS(remote_network_address_arg_ptr);
31899         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
31900         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
31901         int64_t ret_ref = 0;
31902         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31903         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31905         ret_ref = (uintptr_t)ret_var.inner;
31906         if (ret_var.is_owned) {
31907                 ret_ref |= 1;
31908         }
31909         return ret_ref;
31910 }
31911
31912 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
31913         LDKInit ret_var = Init_clone(arg);
31914 int64_t ret_ref = 0;
31915 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31916 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31917 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31918 ret_ref = (uintptr_t)ret_var.inner;
31919 if (ret_var.is_owned) {
31920         ret_ref |= 1;
31921 }
31922         return ret_ref;
31923 }
31924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31925         LDKInit arg_conv;
31926         arg_conv.inner = (void*)(arg & (~1));
31927         arg_conv.is_owned = false;
31928         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31929         int64_t ret_conv = Init_clone_ptr(&arg_conv);
31930         return ret_conv;
31931 }
31932
31933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31934         LDKInit orig_conv;
31935         orig_conv.inner = (void*)(orig & (~1));
31936         orig_conv.is_owned = false;
31937         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31938         LDKInit ret_var = Init_clone(&orig_conv);
31939         int64_t ret_ref = 0;
31940         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31941         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31943         ret_ref = (uintptr_t)ret_var.inner;
31944         if (ret_var.is_owned) {
31945                 ret_ref |= 1;
31946         }
31947         return ret_ref;
31948 }
31949
31950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31951         LDKErrorMessage this_obj_conv;
31952         this_obj_conv.inner = (void*)(this_obj & (~1));
31953         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31955         ErrorMessage_free(this_obj_conv);
31956 }
31957
31958 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31959         LDKErrorMessage this_ptr_conv;
31960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31961         this_ptr_conv.is_owned = false;
31962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31963         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31964         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
31965         return ret_arr;
31966 }
31967
31968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31969         LDKErrorMessage this_ptr_conv;
31970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31971         this_ptr_conv.is_owned = false;
31972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31973         LDKThirtyTwoBytes val_ref;
31974         CHECK((*env)->GetArrayLength(env, val) == 32);
31975         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31976         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
31977 }
31978
31979 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
31980         LDKErrorMessage this_ptr_conv;
31981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31982         this_ptr_conv.is_owned = false;
31983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31984         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
31985         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
31986         Str_free(ret_str);
31987         return ret_conv;
31988 }
31989
31990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
31991         LDKErrorMessage this_ptr_conv;
31992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31993         this_ptr_conv.is_owned = false;
31994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31995         LDKStr val_conv = java_to_owned_str(env, val);
31996         ErrorMessage_set_data(&this_ptr_conv, val_conv);
31997 }
31998
31999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
32000         LDKThirtyTwoBytes channel_id_arg_ref;
32001         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32002         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32003         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
32004         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
32005         int64_t ret_ref = 0;
32006         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32007         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32009         ret_ref = (uintptr_t)ret_var.inner;
32010         if (ret_var.is_owned) {
32011                 ret_ref |= 1;
32012         }
32013         return ret_ref;
32014 }
32015
32016 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
32017         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
32018 int64_t ret_ref = 0;
32019 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32020 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32021 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32022 ret_ref = (uintptr_t)ret_var.inner;
32023 if (ret_var.is_owned) {
32024         ret_ref |= 1;
32025 }
32026         return ret_ref;
32027 }
32028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32029         LDKErrorMessage arg_conv;
32030         arg_conv.inner = (void*)(arg & (~1));
32031         arg_conv.is_owned = false;
32032         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32033         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
32034         return ret_conv;
32035 }
32036
32037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32038         LDKErrorMessage orig_conv;
32039         orig_conv.inner = (void*)(orig & (~1));
32040         orig_conv.is_owned = false;
32041         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32042         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
32043         int64_t ret_ref = 0;
32044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32047         ret_ref = (uintptr_t)ret_var.inner;
32048         if (ret_var.is_owned) {
32049                 ret_ref |= 1;
32050         }
32051         return ret_ref;
32052 }
32053
32054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32055         LDKWarningMessage this_obj_conv;
32056         this_obj_conv.inner = (void*)(this_obj & (~1));
32057         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32059         WarningMessage_free(this_obj_conv);
32060 }
32061
32062 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32063         LDKWarningMessage this_ptr_conv;
32064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32065         this_ptr_conv.is_owned = false;
32066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32067         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32068         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
32069         return ret_arr;
32070 }
32071
32072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32073         LDKWarningMessage this_ptr_conv;
32074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32075         this_ptr_conv.is_owned = false;
32076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32077         LDKThirtyTwoBytes val_ref;
32078         CHECK((*env)->GetArrayLength(env, val) == 32);
32079         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32080         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
32081 }
32082
32083 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
32084         LDKWarningMessage this_ptr_conv;
32085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32086         this_ptr_conv.is_owned = false;
32087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32088         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
32089         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
32090         Str_free(ret_str);
32091         return ret_conv;
32092 }
32093
32094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
32095         LDKWarningMessage this_ptr_conv;
32096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32097         this_ptr_conv.is_owned = false;
32098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32099         LDKStr val_conv = java_to_owned_str(env, val);
32100         WarningMessage_set_data(&this_ptr_conv, val_conv);
32101 }
32102
32103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
32104         LDKThirtyTwoBytes channel_id_arg_ref;
32105         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32106         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32107         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
32108         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
32109         int64_t ret_ref = 0;
32110         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32111         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32113         ret_ref = (uintptr_t)ret_var.inner;
32114         if (ret_var.is_owned) {
32115                 ret_ref |= 1;
32116         }
32117         return ret_ref;
32118 }
32119
32120 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
32121         LDKWarningMessage ret_var = WarningMessage_clone(arg);
32122 int64_t ret_ref = 0;
32123 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32124 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32125 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32126 ret_ref = (uintptr_t)ret_var.inner;
32127 if (ret_var.is_owned) {
32128         ret_ref |= 1;
32129 }
32130         return ret_ref;
32131 }
32132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32133         LDKWarningMessage arg_conv;
32134         arg_conv.inner = (void*)(arg & (~1));
32135         arg_conv.is_owned = false;
32136         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32137         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
32138         return ret_conv;
32139 }
32140
32141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32142         LDKWarningMessage orig_conv;
32143         orig_conv.inner = (void*)(orig & (~1));
32144         orig_conv.is_owned = false;
32145         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32146         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
32147         int64_t ret_ref = 0;
32148         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32149         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32151         ret_ref = (uintptr_t)ret_var.inner;
32152         if (ret_var.is_owned) {
32153                 ret_ref |= 1;
32154         }
32155         return ret_ref;
32156 }
32157
32158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32159         LDKPing this_obj_conv;
32160         this_obj_conv.inner = (void*)(this_obj & (~1));
32161         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32163         Ping_free(this_obj_conv);
32164 }
32165
32166 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
32167         LDKPing this_ptr_conv;
32168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32169         this_ptr_conv.is_owned = false;
32170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32171         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
32172         return ret_conv;
32173 }
32174
32175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32176         LDKPing this_ptr_conv;
32177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32178         this_ptr_conv.is_owned = false;
32179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32180         Ping_set_ponglen(&this_ptr_conv, val);
32181 }
32182
32183 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
32184         LDKPing this_ptr_conv;
32185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32186         this_ptr_conv.is_owned = false;
32187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32188         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
32189         return ret_conv;
32190 }
32191
32192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32193         LDKPing this_ptr_conv;
32194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32195         this_ptr_conv.is_owned = false;
32196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32197         Ping_set_byteslen(&this_ptr_conv, val);
32198 }
32199
32200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
32201         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
32202         int64_t ret_ref = 0;
32203         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32204         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32206         ret_ref = (uintptr_t)ret_var.inner;
32207         if (ret_var.is_owned) {
32208                 ret_ref |= 1;
32209         }
32210         return ret_ref;
32211 }
32212
32213 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
32214         LDKPing ret_var = Ping_clone(arg);
32215 int64_t ret_ref = 0;
32216 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32217 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32218 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32219 ret_ref = (uintptr_t)ret_var.inner;
32220 if (ret_var.is_owned) {
32221         ret_ref |= 1;
32222 }
32223         return ret_ref;
32224 }
32225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32226         LDKPing arg_conv;
32227         arg_conv.inner = (void*)(arg & (~1));
32228         arg_conv.is_owned = false;
32229         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32230         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
32231         return ret_conv;
32232 }
32233
32234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32235         LDKPing orig_conv;
32236         orig_conv.inner = (void*)(orig & (~1));
32237         orig_conv.is_owned = false;
32238         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32239         LDKPing ret_var = Ping_clone(&orig_conv);
32240         int64_t ret_ref = 0;
32241         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32242         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32244         ret_ref = (uintptr_t)ret_var.inner;
32245         if (ret_var.is_owned) {
32246                 ret_ref |= 1;
32247         }
32248         return ret_ref;
32249 }
32250
32251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32252         LDKPong this_obj_conv;
32253         this_obj_conv.inner = (void*)(this_obj & (~1));
32254         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32256         Pong_free(this_obj_conv);
32257 }
32258
32259 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
32260         LDKPong this_ptr_conv;
32261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32262         this_ptr_conv.is_owned = false;
32263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32264         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
32265         return ret_conv;
32266 }
32267
32268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32269         LDKPong this_ptr_conv;
32270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32271         this_ptr_conv.is_owned = false;
32272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32273         Pong_set_byteslen(&this_ptr_conv, val);
32274 }
32275
32276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
32277         LDKPong ret_var = Pong_new(byteslen_arg);
32278         int64_t ret_ref = 0;
32279         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32280         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32282         ret_ref = (uintptr_t)ret_var.inner;
32283         if (ret_var.is_owned) {
32284                 ret_ref |= 1;
32285         }
32286         return ret_ref;
32287 }
32288
32289 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
32290         LDKPong ret_var = Pong_clone(arg);
32291 int64_t ret_ref = 0;
32292 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32293 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32294 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32295 ret_ref = (uintptr_t)ret_var.inner;
32296 if (ret_var.is_owned) {
32297         ret_ref |= 1;
32298 }
32299         return ret_ref;
32300 }
32301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32302         LDKPong arg_conv;
32303         arg_conv.inner = (void*)(arg & (~1));
32304         arg_conv.is_owned = false;
32305         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32306         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
32307         return ret_conv;
32308 }
32309
32310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32311         LDKPong orig_conv;
32312         orig_conv.inner = (void*)(orig & (~1));
32313         orig_conv.is_owned = false;
32314         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32315         LDKPong ret_var = Pong_clone(&orig_conv);
32316         int64_t ret_ref = 0;
32317         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32318         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32320         ret_ref = (uintptr_t)ret_var.inner;
32321         if (ret_var.is_owned) {
32322                 ret_ref |= 1;
32323         }
32324         return ret_ref;
32325 }
32326
32327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32328         LDKOpenChannel this_obj_conv;
32329         this_obj_conv.inner = (void*)(this_obj & (~1));
32330         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32332         OpenChannel_free(this_obj_conv);
32333 }
32334
32335 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
32336         LDKOpenChannel this_ptr_conv;
32337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32338         this_ptr_conv.is_owned = false;
32339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32340         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32341         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
32342         return ret_arr;
32343 }
32344
32345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32346         LDKOpenChannel this_ptr_conv;
32347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32348         this_ptr_conv.is_owned = false;
32349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32350         LDKThirtyTwoBytes val_ref;
32351         CHECK((*env)->GetArrayLength(env, val) == 32);
32352         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32353         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
32354 }
32355
32356 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32357         LDKOpenChannel this_ptr_conv;
32358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32359         this_ptr_conv.is_owned = false;
32360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32361         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32362         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
32363         return ret_arr;
32364 }
32365
32366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32367         LDKOpenChannel this_ptr_conv;
32368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32369         this_ptr_conv.is_owned = false;
32370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32371         LDKThirtyTwoBytes val_ref;
32372         CHECK((*env)->GetArrayLength(env, val) == 32);
32373         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32374         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
32375 }
32376
32377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32378         LDKOpenChannel this_ptr_conv;
32379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32380         this_ptr_conv.is_owned = false;
32381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32382         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
32383         return ret_conv;
32384 }
32385
32386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t 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         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
32392 }
32393
32394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32395         LDKOpenChannel this_ptr_conv;
32396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32397         this_ptr_conv.is_owned = false;
32398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32399         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
32400         return ret_conv;
32401 }
32402
32403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32404         LDKOpenChannel this_ptr_conv;
32405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32406         this_ptr_conv.is_owned = false;
32407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32408         OpenChannel_set_push_msat(&this_ptr_conv, val);
32409 }
32410
32411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32412         LDKOpenChannel this_ptr_conv;
32413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32414         this_ptr_conv.is_owned = false;
32415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32416         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
32417         return ret_conv;
32418 }
32419
32420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32421         LDKOpenChannel this_ptr_conv;
32422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32423         this_ptr_conv.is_owned = false;
32424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32425         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
32426 }
32427
32428 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) {
32429         LDKOpenChannel this_ptr_conv;
32430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32431         this_ptr_conv.is_owned = false;
32432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32433         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
32434         return ret_conv;
32435 }
32436
32437 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) {
32438         LDKOpenChannel this_ptr_conv;
32439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32440         this_ptr_conv.is_owned = false;
32441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32442         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
32443 }
32444
32445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32446         LDKOpenChannel this_ptr_conv;
32447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32448         this_ptr_conv.is_owned = false;
32449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32450         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
32451         return ret_conv;
32452 }
32453
32454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32455         LDKOpenChannel this_ptr_conv;
32456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32457         this_ptr_conv.is_owned = false;
32458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32459         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
32460 }
32461
32462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32463         LDKOpenChannel this_ptr_conv;
32464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32465         this_ptr_conv.is_owned = false;
32466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32467         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
32468         return ret_conv;
32469 }
32470
32471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32472         LDKOpenChannel this_ptr_conv;
32473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32474         this_ptr_conv.is_owned = false;
32475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32476         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
32477 }
32478
32479 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
32480         LDKOpenChannel this_ptr_conv;
32481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32482         this_ptr_conv.is_owned = false;
32483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32484         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
32485         return ret_conv;
32486 }
32487
32488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32489         LDKOpenChannel this_ptr_conv;
32490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32491         this_ptr_conv.is_owned = false;
32492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32493         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
32494 }
32495
32496 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32497         LDKOpenChannel this_ptr_conv;
32498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32499         this_ptr_conv.is_owned = false;
32500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32501         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
32502         return ret_conv;
32503 }
32504
32505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32506         LDKOpenChannel this_ptr_conv;
32507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32508         this_ptr_conv.is_owned = false;
32509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32510         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
32511 }
32512
32513 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
32514         LDKOpenChannel this_ptr_conv;
32515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32516         this_ptr_conv.is_owned = false;
32517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32518         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
32519         return ret_conv;
32520 }
32521
32522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32523         LDKOpenChannel this_ptr_conv;
32524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32525         this_ptr_conv.is_owned = false;
32526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32527         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
32528 }
32529
32530 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32531         LDKOpenChannel this_ptr_conv;
32532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32533         this_ptr_conv.is_owned = false;
32534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32535         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32536         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
32537         return ret_arr;
32538 }
32539
32540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32541         LDKOpenChannel this_ptr_conv;
32542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32543         this_ptr_conv.is_owned = false;
32544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32545         LDKPublicKey val_ref;
32546         CHECK((*env)->GetArrayLength(env, val) == 33);
32547         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32548         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
32549 }
32550
32551 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32552         LDKOpenChannel this_ptr_conv;
32553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32554         this_ptr_conv.is_owned = false;
32555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32556         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32557         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
32558         return ret_arr;
32559 }
32560
32561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32562         LDKOpenChannel this_ptr_conv;
32563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32564         this_ptr_conv.is_owned = false;
32565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32566         LDKPublicKey val_ref;
32567         CHECK((*env)->GetArrayLength(env, val) == 33);
32568         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32569         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
32570 }
32571
32572 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32573         LDKOpenChannel this_ptr_conv;
32574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32575         this_ptr_conv.is_owned = false;
32576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32577         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32578         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
32579         return ret_arr;
32580 }
32581
32582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32583         LDKOpenChannel this_ptr_conv;
32584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32585         this_ptr_conv.is_owned = false;
32586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32587         LDKPublicKey val_ref;
32588         CHECK((*env)->GetArrayLength(env, val) == 33);
32589         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32590         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
32591 }
32592
32593 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32594         LDKOpenChannel this_ptr_conv;
32595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32596         this_ptr_conv.is_owned = false;
32597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32598         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32599         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
32600         return ret_arr;
32601 }
32602
32603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32604         LDKOpenChannel this_ptr_conv;
32605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32606         this_ptr_conv.is_owned = false;
32607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32608         LDKPublicKey val_ref;
32609         CHECK((*env)->GetArrayLength(env, val) == 33);
32610         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32611         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
32612 }
32613
32614 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32615         LDKOpenChannel this_ptr_conv;
32616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32617         this_ptr_conv.is_owned = false;
32618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32619         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32620         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
32621         return ret_arr;
32622 }
32623
32624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32625         LDKOpenChannel this_ptr_conv;
32626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32627         this_ptr_conv.is_owned = false;
32628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32629         LDKPublicKey val_ref;
32630         CHECK((*env)->GetArrayLength(env, val) == 33);
32631         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32632         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
32633 }
32634
32635 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32636         LDKOpenChannel this_ptr_conv;
32637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32638         this_ptr_conv.is_owned = false;
32639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32640         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32641         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
32642         return ret_arr;
32643 }
32644
32645 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) {
32646         LDKOpenChannel this_ptr_conv;
32647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32648         this_ptr_conv.is_owned = false;
32649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32650         LDKPublicKey val_ref;
32651         CHECK((*env)->GetArrayLength(env, val) == 33);
32652         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32653         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
32654 }
32655
32656 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
32657         LDKOpenChannel this_ptr_conv;
32658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32659         this_ptr_conv.is_owned = false;
32660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32661         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
32662         return ret_conv;
32663 }
32664
32665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t 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         OpenChannel_set_channel_flags(&this_ptr_conv, val);
32671 }
32672
32673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
32674         LDKOpenChannel this_ptr_conv;
32675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32676         this_ptr_conv.is_owned = false;
32677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32678         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
32679         int64_t ret_ref = 0;
32680         if ((uintptr_t)ret_var.inner > 4096) {
32681                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32682                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32684                 ret_ref = (uintptr_t)ret_var.inner;
32685                 if (ret_var.is_owned) {
32686                         ret_ref |= 1;
32687                 }
32688         }
32689         return ret_ref;
32690 }
32691
32692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32693         LDKOpenChannel this_ptr_conv;
32694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32695         this_ptr_conv.is_owned = false;
32696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32697         LDKChannelTypeFeatures val_conv;
32698         val_conv.inner = (void*)(val & (~1));
32699         val_conv.is_owned = (val & 1) || (val == 0);
32700         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32701         val_conv = ChannelTypeFeatures_clone(&val_conv);
32702         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
32703 }
32704
32705 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
32706         LDKOpenChannel ret_var = OpenChannel_clone(arg);
32707 int64_t ret_ref = 0;
32708 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32709 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32710 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32711 ret_ref = (uintptr_t)ret_var.inner;
32712 if (ret_var.is_owned) {
32713         ret_ref |= 1;
32714 }
32715         return ret_ref;
32716 }
32717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32718         LDKOpenChannel arg_conv;
32719         arg_conv.inner = (void*)(arg & (~1));
32720         arg_conv.is_owned = false;
32721         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32722         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
32723         return ret_conv;
32724 }
32725
32726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32727         LDKOpenChannel orig_conv;
32728         orig_conv.inner = (void*)(orig & (~1));
32729         orig_conv.is_owned = false;
32730         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32731         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
32732         int64_t ret_ref = 0;
32733         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32734         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32736         ret_ref = (uintptr_t)ret_var.inner;
32737         if (ret_var.is_owned) {
32738                 ret_ref |= 1;
32739         }
32740         return ret_ref;
32741 }
32742
32743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32744         LDKAcceptChannel this_obj_conv;
32745         this_obj_conv.inner = (void*)(this_obj & (~1));
32746         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32748         AcceptChannel_free(this_obj_conv);
32749 }
32750
32751 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32752         LDKAcceptChannel this_ptr_conv;
32753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32754         this_ptr_conv.is_owned = false;
32755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32756         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32757         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
32758         return ret_arr;
32759 }
32760
32761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32762         LDKAcceptChannel this_ptr_conv;
32763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32764         this_ptr_conv.is_owned = false;
32765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32766         LDKThirtyTwoBytes val_ref;
32767         CHECK((*env)->GetArrayLength(env, val) == 32);
32768         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32769         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
32770 }
32771
32772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32773         LDKAcceptChannel this_ptr_conv;
32774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32775         this_ptr_conv.is_owned = false;
32776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32777         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
32778         return ret_conv;
32779 }
32780
32781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t 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         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
32787 }
32788
32789 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) {
32790         LDKAcceptChannel this_ptr_conv;
32791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32792         this_ptr_conv.is_owned = false;
32793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32794         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
32795         return ret_conv;
32796 }
32797
32798 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) {
32799         LDKAcceptChannel this_ptr_conv;
32800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32801         this_ptr_conv.is_owned = false;
32802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32803         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
32804 }
32805
32806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32807         LDKAcceptChannel this_ptr_conv;
32808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32809         this_ptr_conv.is_owned = false;
32810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32811         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
32812         return ret_conv;
32813 }
32814
32815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32816         LDKAcceptChannel this_ptr_conv;
32817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32818         this_ptr_conv.is_owned = false;
32819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32820         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
32821 }
32822
32823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32824         LDKAcceptChannel this_ptr_conv;
32825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32826         this_ptr_conv.is_owned = false;
32827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32828         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
32829         return ret_conv;
32830 }
32831
32832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32833         LDKAcceptChannel this_ptr_conv;
32834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32835         this_ptr_conv.is_owned = false;
32836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32837         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
32838 }
32839
32840 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
32841         LDKAcceptChannel this_ptr_conv;
32842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32843         this_ptr_conv.is_owned = false;
32844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32845         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
32846         return ret_conv;
32847 }
32848
32849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32850         LDKAcceptChannel this_ptr_conv;
32851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32852         this_ptr_conv.is_owned = false;
32853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32854         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
32855 }
32856
32857 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32858         LDKAcceptChannel this_ptr_conv;
32859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32860         this_ptr_conv.is_owned = false;
32861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32862         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
32863         return ret_conv;
32864 }
32865
32866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32867         LDKAcceptChannel this_ptr_conv;
32868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32869         this_ptr_conv.is_owned = false;
32870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32871         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
32872 }
32873
32874 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
32875         LDKAcceptChannel this_ptr_conv;
32876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32877         this_ptr_conv.is_owned = false;
32878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32879         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
32880         return ret_conv;
32881 }
32882
32883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32884         LDKAcceptChannel this_ptr_conv;
32885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32886         this_ptr_conv.is_owned = false;
32887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32888         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
32889 }
32890
32891 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32892         LDKAcceptChannel this_ptr_conv;
32893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32894         this_ptr_conv.is_owned = false;
32895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32896         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32897         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
32898         return ret_arr;
32899 }
32900
32901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32902         LDKAcceptChannel this_ptr_conv;
32903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32904         this_ptr_conv.is_owned = false;
32905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32906         LDKPublicKey val_ref;
32907         CHECK((*env)->GetArrayLength(env, val) == 33);
32908         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32909         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
32910 }
32911
32912 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32913         LDKAcceptChannel this_ptr_conv;
32914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32915         this_ptr_conv.is_owned = false;
32916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32917         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32918         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
32919         return ret_arr;
32920 }
32921
32922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32923         LDKAcceptChannel this_ptr_conv;
32924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32925         this_ptr_conv.is_owned = false;
32926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32927         LDKPublicKey val_ref;
32928         CHECK((*env)->GetArrayLength(env, val) == 33);
32929         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32930         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
32931 }
32932
32933 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32934         LDKAcceptChannel this_ptr_conv;
32935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32936         this_ptr_conv.is_owned = false;
32937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32938         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32939         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
32940         return ret_arr;
32941 }
32942
32943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32944         LDKAcceptChannel this_ptr_conv;
32945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32946         this_ptr_conv.is_owned = false;
32947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32948         LDKPublicKey val_ref;
32949         CHECK((*env)->GetArrayLength(env, val) == 33);
32950         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32951         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
32952 }
32953
32954 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32955         LDKAcceptChannel this_ptr_conv;
32956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32957         this_ptr_conv.is_owned = false;
32958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32959         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32960         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
32961         return ret_arr;
32962 }
32963
32964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32965         LDKAcceptChannel this_ptr_conv;
32966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32967         this_ptr_conv.is_owned = false;
32968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32969         LDKPublicKey val_ref;
32970         CHECK((*env)->GetArrayLength(env, val) == 33);
32971         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32972         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
32973 }
32974
32975 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32976         LDKAcceptChannel this_ptr_conv;
32977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32978         this_ptr_conv.is_owned = false;
32979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32980         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32981         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
32982         return ret_arr;
32983 }
32984
32985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32986         LDKAcceptChannel this_ptr_conv;
32987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32988         this_ptr_conv.is_owned = false;
32989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32990         LDKPublicKey val_ref;
32991         CHECK((*env)->GetArrayLength(env, val) == 33);
32992         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32993         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
32994 }
32995
32996 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32997         LDKAcceptChannel this_ptr_conv;
32998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32999         this_ptr_conv.is_owned = false;
33000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33001         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33002         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
33003         return ret_arr;
33004 }
33005
33006 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) {
33007         LDKAcceptChannel this_ptr_conv;
33008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33009         this_ptr_conv.is_owned = false;
33010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33011         LDKPublicKey val_ref;
33012         CHECK((*env)->GetArrayLength(env, val) == 33);
33013         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33014         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
33015 }
33016
33017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
33018         LDKAcceptChannel this_ptr_conv;
33019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33020         this_ptr_conv.is_owned = false;
33021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33022         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
33023         int64_t ret_ref = 0;
33024         if ((uintptr_t)ret_var.inner > 4096) {
33025                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33026                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33028                 ret_ref = (uintptr_t)ret_var.inner;
33029                 if (ret_var.is_owned) {
33030                         ret_ref |= 1;
33031                 }
33032         }
33033         return ret_ref;
33034 }
33035
33036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33037         LDKAcceptChannel this_ptr_conv;
33038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33039         this_ptr_conv.is_owned = false;
33040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33041         LDKChannelTypeFeatures val_conv;
33042         val_conv.inner = (void*)(val & (~1));
33043         val_conv.is_owned = (val & 1) || (val == 0);
33044         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33045         val_conv = ChannelTypeFeatures_clone(&val_conv);
33046         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
33047 }
33048
33049 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
33050         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
33051 int64_t ret_ref = 0;
33052 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33053 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33054 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33055 ret_ref = (uintptr_t)ret_var.inner;
33056 if (ret_var.is_owned) {
33057         ret_ref |= 1;
33058 }
33059         return ret_ref;
33060 }
33061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33062         LDKAcceptChannel arg_conv;
33063         arg_conv.inner = (void*)(arg & (~1));
33064         arg_conv.is_owned = false;
33065         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33066         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
33067         return ret_conv;
33068 }
33069
33070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33071         LDKAcceptChannel orig_conv;
33072         orig_conv.inner = (void*)(orig & (~1));
33073         orig_conv.is_owned = false;
33074         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33075         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
33076         int64_t ret_ref = 0;
33077         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33078         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33080         ret_ref = (uintptr_t)ret_var.inner;
33081         if (ret_var.is_owned) {
33082                 ret_ref |= 1;
33083         }
33084         return ret_ref;
33085 }
33086
33087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33088         LDKFundingCreated this_obj_conv;
33089         this_obj_conv.inner = (void*)(this_obj & (~1));
33090         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33092         FundingCreated_free(this_obj_conv);
33093 }
33094
33095 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33096         LDKFundingCreated this_ptr_conv;
33097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33098         this_ptr_conv.is_owned = false;
33099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33100         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33101         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
33102         return ret_arr;
33103 }
33104
33105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33106         LDKFundingCreated this_ptr_conv;
33107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33108         this_ptr_conv.is_owned = false;
33109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33110         LDKThirtyTwoBytes val_ref;
33111         CHECK((*env)->GetArrayLength(env, val) == 32);
33112         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33113         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
33114 }
33115
33116 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
33117         LDKFundingCreated this_ptr_conv;
33118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33119         this_ptr_conv.is_owned = false;
33120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33121         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33122         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
33123         return ret_arr;
33124 }
33125
33126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33127         LDKFundingCreated this_ptr_conv;
33128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33129         this_ptr_conv.is_owned = false;
33130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33131         LDKThirtyTwoBytes val_ref;
33132         CHECK((*env)->GetArrayLength(env, val) == 32);
33133         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33134         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
33135 }
33136
33137 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
33138         LDKFundingCreated this_ptr_conv;
33139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33140         this_ptr_conv.is_owned = false;
33141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33142         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
33143         return ret_conv;
33144 }
33145
33146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t 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         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
33152 }
33153
33154 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33155         LDKFundingCreated this_ptr_conv;
33156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33157         this_ptr_conv.is_owned = false;
33158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33159         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33160         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
33161         return ret_arr;
33162 }
33163
33164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33165         LDKFundingCreated this_ptr_conv;
33166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33167         this_ptr_conv.is_owned = false;
33168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33169         LDKSignature val_ref;
33170         CHECK((*env)->GetArrayLength(env, val) == 64);
33171         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33172         FundingCreated_set_signature(&this_ptr_conv, val_ref);
33173 }
33174
33175 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) {
33176         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
33177         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
33178         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
33179         LDKThirtyTwoBytes funding_txid_arg_ref;
33180         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
33181         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
33182         LDKSignature signature_arg_ref;
33183         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33184         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33185         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
33186         int64_t ret_ref = 0;
33187         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33188         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33190         ret_ref = (uintptr_t)ret_var.inner;
33191         if (ret_var.is_owned) {
33192                 ret_ref |= 1;
33193         }
33194         return ret_ref;
33195 }
33196
33197 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
33198         LDKFundingCreated ret_var = FundingCreated_clone(arg);
33199 int64_t ret_ref = 0;
33200 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33201 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33202 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33203 ret_ref = (uintptr_t)ret_var.inner;
33204 if (ret_var.is_owned) {
33205         ret_ref |= 1;
33206 }
33207         return ret_ref;
33208 }
33209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33210         LDKFundingCreated arg_conv;
33211         arg_conv.inner = (void*)(arg & (~1));
33212         arg_conv.is_owned = false;
33213         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33214         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
33215         return ret_conv;
33216 }
33217
33218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33219         LDKFundingCreated orig_conv;
33220         orig_conv.inner = (void*)(orig & (~1));
33221         orig_conv.is_owned = false;
33222         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33223         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
33224         int64_t ret_ref = 0;
33225         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33226         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33228         ret_ref = (uintptr_t)ret_var.inner;
33229         if (ret_var.is_owned) {
33230                 ret_ref |= 1;
33231         }
33232         return ret_ref;
33233 }
33234
33235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33236         LDKFundingSigned this_obj_conv;
33237         this_obj_conv.inner = (void*)(this_obj & (~1));
33238         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33240         FundingSigned_free(this_obj_conv);
33241 }
33242
33243 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33244         LDKFundingSigned this_ptr_conv;
33245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33246         this_ptr_conv.is_owned = false;
33247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33248         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33249         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
33250         return ret_arr;
33251 }
33252
33253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33254         LDKFundingSigned this_ptr_conv;
33255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33256         this_ptr_conv.is_owned = false;
33257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33258         LDKThirtyTwoBytes val_ref;
33259         CHECK((*env)->GetArrayLength(env, val) == 32);
33260         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33261         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
33262 }
33263
33264 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33265         LDKFundingSigned this_ptr_conv;
33266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33267         this_ptr_conv.is_owned = false;
33268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33269         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33270         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
33271         return ret_arr;
33272 }
33273
33274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33275         LDKFundingSigned this_ptr_conv;
33276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33277         this_ptr_conv.is_owned = false;
33278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33279         LDKSignature val_ref;
33280         CHECK((*env)->GetArrayLength(env, val) == 64);
33281         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33282         FundingSigned_set_signature(&this_ptr_conv, val_ref);
33283 }
33284
33285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
33286         LDKThirtyTwoBytes channel_id_arg_ref;
33287         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33288         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33289         LDKSignature signature_arg_ref;
33290         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33291         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33292         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
33293         int64_t ret_ref = 0;
33294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33297         ret_ref = (uintptr_t)ret_var.inner;
33298         if (ret_var.is_owned) {
33299                 ret_ref |= 1;
33300         }
33301         return ret_ref;
33302 }
33303
33304 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
33305         LDKFundingSigned ret_var = FundingSigned_clone(arg);
33306 int64_t ret_ref = 0;
33307 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33308 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33309 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33310 ret_ref = (uintptr_t)ret_var.inner;
33311 if (ret_var.is_owned) {
33312         ret_ref |= 1;
33313 }
33314         return ret_ref;
33315 }
33316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33317         LDKFundingSigned arg_conv;
33318         arg_conv.inner = (void*)(arg & (~1));
33319         arg_conv.is_owned = false;
33320         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33321         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
33322         return ret_conv;
33323 }
33324
33325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33326         LDKFundingSigned orig_conv;
33327         orig_conv.inner = (void*)(orig & (~1));
33328         orig_conv.is_owned = false;
33329         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33330         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
33331         int64_t ret_ref = 0;
33332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33335         ret_ref = (uintptr_t)ret_var.inner;
33336         if (ret_var.is_owned) {
33337                 ret_ref |= 1;
33338         }
33339         return ret_ref;
33340 }
33341
33342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33343         LDKChannelReady this_obj_conv;
33344         this_obj_conv.inner = (void*)(this_obj & (~1));
33345         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33347         ChannelReady_free(this_obj_conv);
33348 }
33349
33350 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33351         LDKChannelReady this_ptr_conv;
33352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33353         this_ptr_conv.is_owned = false;
33354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33355         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33356         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReady_get_channel_id(&this_ptr_conv));
33357         return ret_arr;
33358 }
33359
33360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33361         LDKChannelReady this_ptr_conv;
33362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33363         this_ptr_conv.is_owned = false;
33364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33365         LDKThirtyTwoBytes val_ref;
33366         CHECK((*env)->GetArrayLength(env, val) == 32);
33367         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33368         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
33369 }
33370
33371 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33372         LDKChannelReady this_ptr_conv;
33373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33374         this_ptr_conv.is_owned = false;
33375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33376         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33377         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
33378         return ret_arr;
33379 }
33380
33381 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) {
33382         LDKChannelReady this_ptr_conv;
33383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33384         this_ptr_conv.is_owned = false;
33385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33386         LDKPublicKey val_ref;
33387         CHECK((*env)->GetArrayLength(env, val) == 33);
33388         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33389         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
33390 }
33391
33392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
33393         LDKChannelReady this_ptr_conv;
33394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33395         this_ptr_conv.is_owned = false;
33396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33397         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
33398         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
33399         int64_t ret_ref = (uintptr_t)ret_copy;
33400         return ret_ref;
33401 }
33402
33403 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) {
33404         LDKChannelReady this_ptr_conv;
33405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33406         this_ptr_conv.is_owned = false;
33407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33408         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33409         CHECK_ACCESS(val_ptr);
33410         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
33411         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
33412         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
33413 }
33414
33415 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) {
33416         LDKThirtyTwoBytes channel_id_arg_ref;
33417         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33418         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33419         LDKPublicKey next_per_commitment_point_arg_ref;
33420         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
33421         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
33422         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
33423         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
33424         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
33425         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
33426         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
33427         int64_t ret_ref = 0;
33428         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33429         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33431         ret_ref = (uintptr_t)ret_var.inner;
33432         if (ret_var.is_owned) {
33433                 ret_ref |= 1;
33434         }
33435         return ret_ref;
33436 }
33437
33438 static inline uintptr_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
33439         LDKChannelReady ret_var = ChannelReady_clone(arg);
33440 int64_t ret_ref = 0;
33441 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33442 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33443 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33444 ret_ref = (uintptr_t)ret_var.inner;
33445 if (ret_var.is_owned) {
33446         ret_ref |= 1;
33447 }
33448         return ret_ref;
33449 }
33450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33451         LDKChannelReady arg_conv;
33452         arg_conv.inner = (void*)(arg & (~1));
33453         arg_conv.is_owned = false;
33454         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33455         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
33456         return ret_conv;
33457 }
33458
33459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33460         LDKChannelReady orig_conv;
33461         orig_conv.inner = (void*)(orig & (~1));
33462         orig_conv.is_owned = false;
33463         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33464         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
33465         int64_t ret_ref = 0;
33466         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33467         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33469         ret_ref = (uintptr_t)ret_var.inner;
33470         if (ret_var.is_owned) {
33471                 ret_ref |= 1;
33472         }
33473         return ret_ref;
33474 }
33475
33476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33477         LDKShutdown this_obj_conv;
33478         this_obj_conv.inner = (void*)(this_obj & (~1));
33479         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33481         Shutdown_free(this_obj_conv);
33482 }
33483
33484 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33485         LDKShutdown this_ptr_conv;
33486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33487         this_ptr_conv.is_owned = false;
33488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33489         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33490         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
33491         return ret_arr;
33492 }
33493
33494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33495         LDKShutdown this_ptr_conv;
33496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33497         this_ptr_conv.is_owned = false;
33498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33499         LDKThirtyTwoBytes val_ref;
33500         CHECK((*env)->GetArrayLength(env, val) == 32);
33501         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33502         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
33503 }
33504
33505 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
33506         LDKShutdown this_ptr_conv;
33507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33508         this_ptr_conv.is_owned = false;
33509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33510         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
33511         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33512         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33513         return ret_arr;
33514 }
33515
33516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33517         LDKShutdown this_ptr_conv;
33518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33519         this_ptr_conv.is_owned = false;
33520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33521         LDKCVec_u8Z val_ref;
33522         val_ref.datalen = (*env)->GetArrayLength(env, val);
33523         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
33524         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
33525         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
33526 }
33527
33528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
33529         LDKThirtyTwoBytes channel_id_arg_ref;
33530         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33531         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33532         LDKCVec_u8Z scriptpubkey_arg_ref;
33533         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
33534         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
33535         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
33536         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
33537         int64_t ret_ref = 0;
33538         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33539         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33541         ret_ref = (uintptr_t)ret_var.inner;
33542         if (ret_var.is_owned) {
33543                 ret_ref |= 1;
33544         }
33545         return ret_ref;
33546 }
33547
33548 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
33549         LDKShutdown ret_var = Shutdown_clone(arg);
33550 int64_t ret_ref = 0;
33551 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33552 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33553 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33554 ret_ref = (uintptr_t)ret_var.inner;
33555 if (ret_var.is_owned) {
33556         ret_ref |= 1;
33557 }
33558         return ret_ref;
33559 }
33560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33561         LDKShutdown arg_conv;
33562         arg_conv.inner = (void*)(arg & (~1));
33563         arg_conv.is_owned = false;
33564         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33565         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
33566         return ret_conv;
33567 }
33568
33569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33570         LDKShutdown orig_conv;
33571         orig_conv.inner = (void*)(orig & (~1));
33572         orig_conv.is_owned = false;
33573         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33574         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
33575         int64_t ret_ref = 0;
33576         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33577         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33578         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33579         ret_ref = (uintptr_t)ret_var.inner;
33580         if (ret_var.is_owned) {
33581                 ret_ref |= 1;
33582         }
33583         return ret_ref;
33584 }
33585
33586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33587         LDKClosingSignedFeeRange this_obj_conv;
33588         this_obj_conv.inner = (void*)(this_obj & (~1));
33589         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33591         ClosingSignedFeeRange_free(this_obj_conv);
33592 }
33593
33594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33595         LDKClosingSignedFeeRange this_ptr_conv;
33596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33597         this_ptr_conv.is_owned = false;
33598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33599         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
33600         return ret_conv;
33601 }
33602
33603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33604         LDKClosingSignedFeeRange this_ptr_conv;
33605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33606         this_ptr_conv.is_owned = false;
33607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33608         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
33609 }
33610
33611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33612         LDKClosingSignedFeeRange this_ptr_conv;
33613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33614         this_ptr_conv.is_owned = false;
33615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33616         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
33617         return ret_conv;
33618 }
33619
33620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33621         LDKClosingSignedFeeRange this_ptr_conv;
33622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33623         this_ptr_conv.is_owned = false;
33624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33625         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
33626 }
33627
33628 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) {
33629         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
33630         int64_t ret_ref = 0;
33631         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33632         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33634         ret_ref = (uintptr_t)ret_var.inner;
33635         if (ret_var.is_owned) {
33636                 ret_ref |= 1;
33637         }
33638         return ret_ref;
33639 }
33640
33641 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
33642         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
33643 int64_t ret_ref = 0;
33644 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33645 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33646 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33647 ret_ref = (uintptr_t)ret_var.inner;
33648 if (ret_var.is_owned) {
33649         ret_ref |= 1;
33650 }
33651         return ret_ref;
33652 }
33653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33654         LDKClosingSignedFeeRange arg_conv;
33655         arg_conv.inner = (void*)(arg & (~1));
33656         arg_conv.is_owned = false;
33657         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33658         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
33659         return ret_conv;
33660 }
33661
33662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33663         LDKClosingSignedFeeRange orig_conv;
33664         orig_conv.inner = (void*)(orig & (~1));
33665         orig_conv.is_owned = false;
33666         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33667         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
33668         int64_t ret_ref = 0;
33669         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33670         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33672         ret_ref = (uintptr_t)ret_var.inner;
33673         if (ret_var.is_owned) {
33674                 ret_ref |= 1;
33675         }
33676         return ret_ref;
33677 }
33678
33679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33680         LDKClosingSigned this_obj_conv;
33681         this_obj_conv.inner = (void*)(this_obj & (~1));
33682         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33684         ClosingSigned_free(this_obj_conv);
33685 }
33686
33687 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33688         LDKClosingSigned this_ptr_conv;
33689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33690         this_ptr_conv.is_owned = false;
33691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33692         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33693         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
33694         return ret_arr;
33695 }
33696
33697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33698         LDKClosingSigned this_ptr_conv;
33699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33700         this_ptr_conv.is_owned = false;
33701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33702         LDKThirtyTwoBytes val_ref;
33703         CHECK((*env)->GetArrayLength(env, val) == 32);
33704         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33705         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
33706 }
33707
33708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33709         LDKClosingSigned this_ptr_conv;
33710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33711         this_ptr_conv.is_owned = false;
33712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33713         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
33714         return ret_conv;
33715 }
33716
33717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t 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         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
33723 }
33724
33725 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33726         LDKClosingSigned this_ptr_conv;
33727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33728         this_ptr_conv.is_owned = false;
33729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33730         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33731         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
33732         return ret_arr;
33733 }
33734
33735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33736         LDKClosingSigned this_ptr_conv;
33737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33738         this_ptr_conv.is_owned = false;
33739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33740         LDKSignature val_ref;
33741         CHECK((*env)->GetArrayLength(env, val) == 64);
33742         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33743         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
33744 }
33745
33746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
33747         LDKClosingSigned this_ptr_conv;
33748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33749         this_ptr_conv.is_owned = false;
33750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33751         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
33752         int64_t ret_ref = 0;
33753         if ((uintptr_t)ret_var.inner > 4096) {
33754                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33755                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33757                 ret_ref = (uintptr_t)ret_var.inner;
33758                 if (ret_var.is_owned) {
33759                         ret_ref |= 1;
33760                 }
33761         }
33762         return ret_ref;
33763 }
33764
33765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33766         LDKClosingSigned this_ptr_conv;
33767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33768         this_ptr_conv.is_owned = false;
33769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33770         LDKClosingSignedFeeRange val_conv;
33771         val_conv.inner = (void*)(val & (~1));
33772         val_conv.is_owned = (val & 1) || (val == 0);
33773         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33774         val_conv = ClosingSignedFeeRange_clone(&val_conv);
33775         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
33776 }
33777
33778 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) {
33779         LDKThirtyTwoBytes channel_id_arg_ref;
33780         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33781         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33782         LDKSignature signature_arg_ref;
33783         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33784         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33785         LDKClosingSignedFeeRange fee_range_arg_conv;
33786         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
33787         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
33788         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
33789         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
33790         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
33791         int64_t ret_ref = 0;
33792         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33793         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33795         ret_ref = (uintptr_t)ret_var.inner;
33796         if (ret_var.is_owned) {
33797                 ret_ref |= 1;
33798         }
33799         return ret_ref;
33800 }
33801
33802 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
33803         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
33804 int64_t ret_ref = 0;
33805 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33806 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33807 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33808 ret_ref = (uintptr_t)ret_var.inner;
33809 if (ret_var.is_owned) {
33810         ret_ref |= 1;
33811 }
33812         return ret_ref;
33813 }
33814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33815         LDKClosingSigned arg_conv;
33816         arg_conv.inner = (void*)(arg & (~1));
33817         arg_conv.is_owned = false;
33818         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33819         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
33820         return ret_conv;
33821 }
33822
33823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33824         LDKClosingSigned orig_conv;
33825         orig_conv.inner = (void*)(orig & (~1));
33826         orig_conv.is_owned = false;
33827         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33828         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
33829         int64_t ret_ref = 0;
33830         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33831         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33832         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33833         ret_ref = (uintptr_t)ret_var.inner;
33834         if (ret_var.is_owned) {
33835                 ret_ref |= 1;
33836         }
33837         return ret_ref;
33838 }
33839
33840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33841         LDKUpdateAddHTLC this_obj_conv;
33842         this_obj_conv.inner = (void*)(this_obj & (~1));
33843         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33845         UpdateAddHTLC_free(this_obj_conv);
33846 }
33847
33848 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33849         LDKUpdateAddHTLC this_ptr_conv;
33850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33851         this_ptr_conv.is_owned = false;
33852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33853         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33854         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
33855         return ret_arr;
33856 }
33857
33858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33859         LDKUpdateAddHTLC this_ptr_conv;
33860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33861         this_ptr_conv.is_owned = false;
33862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33863         LDKThirtyTwoBytes val_ref;
33864         CHECK((*env)->GetArrayLength(env, val) == 32);
33865         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33866         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
33867 }
33868
33869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33870         LDKUpdateAddHTLC this_ptr_conv;
33871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33872         this_ptr_conv.is_owned = false;
33873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33874         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
33875         return ret_conv;
33876 }
33877
33878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t 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         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
33884 }
33885
33886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33887         LDKUpdateAddHTLC this_ptr_conv;
33888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33889         this_ptr_conv.is_owned = false;
33890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33891         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
33892         return ret_conv;
33893 }
33894
33895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33896         LDKUpdateAddHTLC this_ptr_conv;
33897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33898         this_ptr_conv.is_owned = false;
33899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33900         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
33901 }
33902
33903 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33904         LDKUpdateAddHTLC this_ptr_conv;
33905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33906         this_ptr_conv.is_owned = false;
33907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33908         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33909         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
33910         return ret_arr;
33911 }
33912
33913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33914         LDKUpdateAddHTLC this_ptr_conv;
33915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33916         this_ptr_conv.is_owned = false;
33917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33918         LDKThirtyTwoBytes val_ref;
33919         CHECK((*env)->GetArrayLength(env, val) == 32);
33920         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33921         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
33922 }
33923
33924 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
33925         LDKUpdateAddHTLC this_ptr_conv;
33926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33927         this_ptr_conv.is_owned = false;
33928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33929         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
33930         return ret_conv;
33931 }
33932
33933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t 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         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
33939 }
33940
33941 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
33942         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
33943 int64_t ret_ref = 0;
33944 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33945 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33946 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33947 ret_ref = (uintptr_t)ret_var.inner;
33948 if (ret_var.is_owned) {
33949         ret_ref |= 1;
33950 }
33951         return ret_ref;
33952 }
33953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33954         LDKUpdateAddHTLC arg_conv;
33955         arg_conv.inner = (void*)(arg & (~1));
33956         arg_conv.is_owned = false;
33957         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33958         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
33959         return ret_conv;
33960 }
33961
33962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33963         LDKUpdateAddHTLC orig_conv;
33964         orig_conv.inner = (void*)(orig & (~1));
33965         orig_conv.is_owned = false;
33966         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33967         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
33968         int64_t ret_ref = 0;
33969         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33970         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33972         ret_ref = (uintptr_t)ret_var.inner;
33973         if (ret_var.is_owned) {
33974                 ret_ref |= 1;
33975         }
33976         return ret_ref;
33977 }
33978
33979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33980         LDKUpdateFulfillHTLC this_obj_conv;
33981         this_obj_conv.inner = (void*)(this_obj & (~1));
33982         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33984         UpdateFulfillHTLC_free(this_obj_conv);
33985 }
33986
33987 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33988         LDKUpdateFulfillHTLC this_ptr_conv;
33989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33990         this_ptr_conv.is_owned = false;
33991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33992         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33993         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
33994         return ret_arr;
33995 }
33996
33997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33998         LDKUpdateFulfillHTLC this_ptr_conv;
33999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34000         this_ptr_conv.is_owned = false;
34001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34002         LDKThirtyTwoBytes val_ref;
34003         CHECK((*env)->GetArrayLength(env, val) == 32);
34004         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34005         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
34006 }
34007
34008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34009         LDKUpdateFulfillHTLC this_ptr_conv;
34010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34011         this_ptr_conv.is_owned = false;
34012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34013         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
34014         return ret_conv;
34015 }
34016
34017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t 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         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
34023 }
34024
34025 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
34026         LDKUpdateFulfillHTLC this_ptr_conv;
34027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34028         this_ptr_conv.is_owned = false;
34029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34030         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34031         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
34032         return ret_arr;
34033 }
34034
34035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34036         LDKUpdateFulfillHTLC this_ptr_conv;
34037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34038         this_ptr_conv.is_owned = false;
34039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34040         LDKThirtyTwoBytes val_ref;
34041         CHECK((*env)->GetArrayLength(env, val) == 32);
34042         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34043         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
34044 }
34045
34046 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) {
34047         LDKThirtyTwoBytes channel_id_arg_ref;
34048         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34049         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34050         LDKThirtyTwoBytes payment_preimage_arg_ref;
34051         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
34052         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
34053         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
34054         int64_t ret_ref = 0;
34055         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34056         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34058         ret_ref = (uintptr_t)ret_var.inner;
34059         if (ret_var.is_owned) {
34060                 ret_ref |= 1;
34061         }
34062         return ret_ref;
34063 }
34064
34065 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
34066         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
34067 int64_t ret_ref = 0;
34068 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34069 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34070 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34071 ret_ref = (uintptr_t)ret_var.inner;
34072 if (ret_var.is_owned) {
34073         ret_ref |= 1;
34074 }
34075         return ret_ref;
34076 }
34077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34078         LDKUpdateFulfillHTLC arg_conv;
34079         arg_conv.inner = (void*)(arg & (~1));
34080         arg_conv.is_owned = false;
34081         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34082         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
34083         return ret_conv;
34084 }
34085
34086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34087         LDKUpdateFulfillHTLC orig_conv;
34088         orig_conv.inner = (void*)(orig & (~1));
34089         orig_conv.is_owned = false;
34090         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34091         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
34092         int64_t ret_ref = 0;
34093         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34094         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34096         ret_ref = (uintptr_t)ret_var.inner;
34097         if (ret_var.is_owned) {
34098                 ret_ref |= 1;
34099         }
34100         return ret_ref;
34101 }
34102
34103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34104         LDKUpdateFailHTLC this_obj_conv;
34105         this_obj_conv.inner = (void*)(this_obj & (~1));
34106         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34108         UpdateFailHTLC_free(this_obj_conv);
34109 }
34110
34111 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34112         LDKUpdateFailHTLC this_ptr_conv;
34113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34114         this_ptr_conv.is_owned = false;
34115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34116         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34117         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
34118         return ret_arr;
34119 }
34120
34121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34122         LDKUpdateFailHTLC this_ptr_conv;
34123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34124         this_ptr_conv.is_owned = false;
34125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34126         LDKThirtyTwoBytes val_ref;
34127         CHECK((*env)->GetArrayLength(env, val) == 32);
34128         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34129         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
34130 }
34131
34132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34133         LDKUpdateFailHTLC this_ptr_conv;
34134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34135         this_ptr_conv.is_owned = false;
34136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34137         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
34138         return ret_conv;
34139 }
34140
34141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t 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         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
34147 }
34148
34149 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
34150         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
34151 int64_t ret_ref = 0;
34152 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34153 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34154 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34155 ret_ref = (uintptr_t)ret_var.inner;
34156 if (ret_var.is_owned) {
34157         ret_ref |= 1;
34158 }
34159         return ret_ref;
34160 }
34161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34162         LDKUpdateFailHTLC arg_conv;
34163         arg_conv.inner = (void*)(arg & (~1));
34164         arg_conv.is_owned = false;
34165         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34166         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
34167         return ret_conv;
34168 }
34169
34170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34171         LDKUpdateFailHTLC orig_conv;
34172         orig_conv.inner = (void*)(orig & (~1));
34173         orig_conv.is_owned = false;
34174         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34175         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
34176         int64_t ret_ref = 0;
34177         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34178         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34180         ret_ref = (uintptr_t)ret_var.inner;
34181         if (ret_var.is_owned) {
34182                 ret_ref |= 1;
34183         }
34184         return ret_ref;
34185 }
34186
34187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34188         LDKUpdateFailMalformedHTLC this_obj_conv;
34189         this_obj_conv.inner = (void*)(this_obj & (~1));
34190         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34192         UpdateFailMalformedHTLC_free(this_obj_conv);
34193 }
34194
34195 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34196         LDKUpdateFailMalformedHTLC this_ptr_conv;
34197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34198         this_ptr_conv.is_owned = false;
34199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34200         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34201         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
34202         return ret_arr;
34203 }
34204
34205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34206         LDKUpdateFailMalformedHTLC this_ptr_conv;
34207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34208         this_ptr_conv.is_owned = false;
34209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34210         LDKThirtyTwoBytes val_ref;
34211         CHECK((*env)->GetArrayLength(env, val) == 32);
34212         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34213         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
34214 }
34215
34216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34217         LDKUpdateFailMalformedHTLC this_ptr_conv;
34218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34219         this_ptr_conv.is_owned = false;
34220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34221         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
34222         return ret_conv;
34223 }
34224
34225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t 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         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
34231 }
34232
34233 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
34234         LDKUpdateFailMalformedHTLC this_ptr_conv;
34235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34236         this_ptr_conv.is_owned = false;
34237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34238         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
34239         return ret_conv;
34240 }
34241
34242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34243         LDKUpdateFailMalformedHTLC this_ptr_conv;
34244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34245         this_ptr_conv.is_owned = false;
34246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34247         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
34248 }
34249
34250 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
34251         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
34252 int64_t ret_ref = 0;
34253 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34254 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34255 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34256 ret_ref = (uintptr_t)ret_var.inner;
34257 if (ret_var.is_owned) {
34258         ret_ref |= 1;
34259 }
34260         return ret_ref;
34261 }
34262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34263         LDKUpdateFailMalformedHTLC arg_conv;
34264         arg_conv.inner = (void*)(arg & (~1));
34265         arg_conv.is_owned = false;
34266         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34267         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
34268         return ret_conv;
34269 }
34270
34271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34272         LDKUpdateFailMalformedHTLC orig_conv;
34273         orig_conv.inner = (void*)(orig & (~1));
34274         orig_conv.is_owned = false;
34275         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34276         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
34277         int64_t ret_ref = 0;
34278         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34279         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34281         ret_ref = (uintptr_t)ret_var.inner;
34282         if (ret_var.is_owned) {
34283                 ret_ref |= 1;
34284         }
34285         return ret_ref;
34286 }
34287
34288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34289         LDKCommitmentSigned this_obj_conv;
34290         this_obj_conv.inner = (void*)(this_obj & (~1));
34291         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34293         CommitmentSigned_free(this_obj_conv);
34294 }
34295
34296 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34297         LDKCommitmentSigned this_ptr_conv;
34298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34299         this_ptr_conv.is_owned = false;
34300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34301         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34302         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
34303         return ret_arr;
34304 }
34305
34306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34307         LDKCommitmentSigned this_ptr_conv;
34308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34309         this_ptr_conv.is_owned = false;
34310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34311         LDKThirtyTwoBytes val_ref;
34312         CHECK((*env)->GetArrayLength(env, val) == 32);
34313         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34314         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
34315 }
34316
34317 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34318         LDKCommitmentSigned this_ptr_conv;
34319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34320         this_ptr_conv.is_owned = false;
34321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34322         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34323         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
34324         return ret_arr;
34325 }
34326
34327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34328         LDKCommitmentSigned this_ptr_conv;
34329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34330         this_ptr_conv.is_owned = false;
34331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34332         LDKSignature val_ref;
34333         CHECK((*env)->GetArrayLength(env, val) == 64);
34334         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34335         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
34336 }
34337
34338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
34339         LDKCommitmentSigned this_ptr_conv;
34340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34341         this_ptr_conv.is_owned = false;
34342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34343         LDKCVec_SignatureZ val_constr;
34344         val_constr.datalen = (*env)->GetArrayLength(env, val);
34345         if (val_constr.datalen > 0)
34346                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34347         else
34348                 val_constr.data = NULL;
34349         for (size_t i = 0; i < val_constr.datalen; i++) {
34350                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
34351                 LDKSignature val_conv_8_ref;
34352                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
34353                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
34354                 val_constr.data[i] = val_conv_8_ref;
34355         }
34356         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
34357 }
34358
34359 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) {
34360         LDKThirtyTwoBytes channel_id_arg_ref;
34361         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34362         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34363         LDKSignature signature_arg_ref;
34364         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34365         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34366         LDKCVec_SignatureZ htlc_signatures_arg_constr;
34367         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
34368         if (htlc_signatures_arg_constr.datalen > 0)
34369                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34370         else
34371                 htlc_signatures_arg_constr.data = NULL;
34372         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
34373                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
34374                 LDKSignature htlc_signatures_arg_conv_8_ref;
34375                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
34376                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
34377                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
34378         }
34379         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
34380         int64_t ret_ref = 0;
34381         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34382         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34384         ret_ref = (uintptr_t)ret_var.inner;
34385         if (ret_var.is_owned) {
34386                 ret_ref |= 1;
34387         }
34388         return ret_ref;
34389 }
34390
34391 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
34392         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
34393 int64_t ret_ref = 0;
34394 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34395 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34396 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34397 ret_ref = (uintptr_t)ret_var.inner;
34398 if (ret_var.is_owned) {
34399         ret_ref |= 1;
34400 }
34401         return ret_ref;
34402 }
34403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34404         LDKCommitmentSigned arg_conv;
34405         arg_conv.inner = (void*)(arg & (~1));
34406         arg_conv.is_owned = false;
34407         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34408         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
34409         return ret_conv;
34410 }
34411
34412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34413         LDKCommitmentSigned orig_conv;
34414         orig_conv.inner = (void*)(orig & (~1));
34415         orig_conv.is_owned = false;
34416         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34417         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
34418         int64_t ret_ref = 0;
34419         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34420         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34422         ret_ref = (uintptr_t)ret_var.inner;
34423         if (ret_var.is_owned) {
34424                 ret_ref |= 1;
34425         }
34426         return ret_ref;
34427 }
34428
34429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34430         LDKRevokeAndACK this_obj_conv;
34431         this_obj_conv.inner = (void*)(this_obj & (~1));
34432         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34434         RevokeAndACK_free(this_obj_conv);
34435 }
34436
34437 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34438         LDKRevokeAndACK this_ptr_conv;
34439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34440         this_ptr_conv.is_owned = false;
34441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34442         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34443         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
34444         return ret_arr;
34445 }
34446
34447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34448         LDKRevokeAndACK this_ptr_conv;
34449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34450         this_ptr_conv.is_owned = false;
34451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34452         LDKThirtyTwoBytes val_ref;
34453         CHECK((*env)->GetArrayLength(env, val) == 32);
34454         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34455         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
34456 }
34457
34458 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
34459         LDKRevokeAndACK this_ptr_conv;
34460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34461         this_ptr_conv.is_owned = false;
34462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34463         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34464         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
34465         return ret_arr;
34466 }
34467
34468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34469         LDKRevokeAndACK this_ptr_conv;
34470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34471         this_ptr_conv.is_owned = false;
34472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34473         LDKThirtyTwoBytes val_ref;
34474         CHECK((*env)->GetArrayLength(env, val) == 32);
34475         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34476         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
34477 }
34478
34479 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34480         LDKRevokeAndACK this_ptr_conv;
34481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34482         this_ptr_conv.is_owned = false;
34483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34484         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34485         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
34486         return ret_arr;
34487 }
34488
34489 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) {
34490         LDKRevokeAndACK this_ptr_conv;
34491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34492         this_ptr_conv.is_owned = false;
34493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34494         LDKPublicKey val_ref;
34495         CHECK((*env)->GetArrayLength(env, val) == 33);
34496         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34497         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
34498 }
34499
34500 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) {
34501         LDKThirtyTwoBytes channel_id_arg_ref;
34502         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34503         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34504         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
34505         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
34506         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
34507         LDKPublicKey next_per_commitment_point_arg_ref;
34508         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
34509         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
34510         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
34511         int64_t ret_ref = 0;
34512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34515         ret_ref = (uintptr_t)ret_var.inner;
34516         if (ret_var.is_owned) {
34517                 ret_ref |= 1;
34518         }
34519         return ret_ref;
34520 }
34521
34522 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
34523         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
34524 int64_t ret_ref = 0;
34525 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34526 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34527 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34528 ret_ref = (uintptr_t)ret_var.inner;
34529 if (ret_var.is_owned) {
34530         ret_ref |= 1;
34531 }
34532         return ret_ref;
34533 }
34534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34535         LDKRevokeAndACK arg_conv;
34536         arg_conv.inner = (void*)(arg & (~1));
34537         arg_conv.is_owned = false;
34538         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34539         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
34540         return ret_conv;
34541 }
34542
34543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34544         LDKRevokeAndACK orig_conv;
34545         orig_conv.inner = (void*)(orig & (~1));
34546         orig_conv.is_owned = false;
34547         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34548         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
34549         int64_t ret_ref = 0;
34550         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34551         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34553         ret_ref = (uintptr_t)ret_var.inner;
34554         if (ret_var.is_owned) {
34555                 ret_ref |= 1;
34556         }
34557         return ret_ref;
34558 }
34559
34560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34561         LDKUpdateFee this_obj_conv;
34562         this_obj_conv.inner = (void*)(this_obj & (~1));
34563         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34565         UpdateFee_free(this_obj_conv);
34566 }
34567
34568 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34569         LDKUpdateFee this_ptr_conv;
34570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34571         this_ptr_conv.is_owned = false;
34572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34573         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34574         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
34575         return ret_arr;
34576 }
34577
34578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34579         LDKUpdateFee this_ptr_conv;
34580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34581         this_ptr_conv.is_owned = false;
34582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34583         LDKThirtyTwoBytes val_ref;
34584         CHECK((*env)->GetArrayLength(env, val) == 32);
34585         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34586         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
34587 }
34588
34589 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
34590         LDKUpdateFee this_ptr_conv;
34591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34592         this_ptr_conv.is_owned = false;
34593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34594         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
34595         return ret_conv;
34596 }
34597
34598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34599         LDKUpdateFee this_ptr_conv;
34600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34601         this_ptr_conv.is_owned = false;
34602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34603         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
34604 }
34605
34606 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) {
34607         LDKThirtyTwoBytes channel_id_arg_ref;
34608         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34609         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34610         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
34611         int64_t ret_ref = 0;
34612         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34613         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34615         ret_ref = (uintptr_t)ret_var.inner;
34616         if (ret_var.is_owned) {
34617                 ret_ref |= 1;
34618         }
34619         return ret_ref;
34620 }
34621
34622 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
34623         LDKUpdateFee ret_var = UpdateFee_clone(arg);
34624 int64_t ret_ref = 0;
34625 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34626 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34627 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34628 ret_ref = (uintptr_t)ret_var.inner;
34629 if (ret_var.is_owned) {
34630         ret_ref |= 1;
34631 }
34632         return ret_ref;
34633 }
34634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34635         LDKUpdateFee arg_conv;
34636         arg_conv.inner = (void*)(arg & (~1));
34637         arg_conv.is_owned = false;
34638         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34639         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
34640         return ret_conv;
34641 }
34642
34643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34644         LDKUpdateFee orig_conv;
34645         orig_conv.inner = (void*)(orig & (~1));
34646         orig_conv.is_owned = false;
34647         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34648         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
34649         int64_t ret_ref = 0;
34650         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34651         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34653         ret_ref = (uintptr_t)ret_var.inner;
34654         if (ret_var.is_owned) {
34655                 ret_ref |= 1;
34656         }
34657         return ret_ref;
34658 }
34659
34660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34661         LDKDataLossProtect this_obj_conv;
34662         this_obj_conv.inner = (void*)(this_obj & (~1));
34663         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34665         DataLossProtect_free(this_obj_conv);
34666 }
34667
34668 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
34669         LDKDataLossProtect this_ptr_conv;
34670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34671         this_ptr_conv.is_owned = false;
34672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34673         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34674         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
34675         return ret_arr;
34676 }
34677
34678 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) {
34679         LDKDataLossProtect this_ptr_conv;
34680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34681         this_ptr_conv.is_owned = false;
34682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34683         LDKThirtyTwoBytes val_ref;
34684         CHECK((*env)->GetArrayLength(env, val) == 32);
34685         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34686         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
34687 }
34688
34689 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34690         LDKDataLossProtect this_ptr_conv;
34691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34692         this_ptr_conv.is_owned = false;
34693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34694         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34695         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
34696         return ret_arr;
34697 }
34698
34699 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) {
34700         LDKDataLossProtect this_ptr_conv;
34701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34702         this_ptr_conv.is_owned = false;
34703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34704         LDKPublicKey val_ref;
34705         CHECK((*env)->GetArrayLength(env, val) == 33);
34706         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34707         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
34708 }
34709
34710 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) {
34711         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
34712         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
34713         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
34714         LDKPublicKey my_current_per_commitment_point_arg_ref;
34715         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
34716         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
34717         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
34718         int64_t ret_ref = 0;
34719         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34720         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34722         ret_ref = (uintptr_t)ret_var.inner;
34723         if (ret_var.is_owned) {
34724                 ret_ref |= 1;
34725         }
34726         return ret_ref;
34727 }
34728
34729 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
34730         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
34731 int64_t ret_ref = 0;
34732 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34733 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34734 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34735 ret_ref = (uintptr_t)ret_var.inner;
34736 if (ret_var.is_owned) {
34737         ret_ref |= 1;
34738 }
34739         return ret_ref;
34740 }
34741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34742         LDKDataLossProtect arg_conv;
34743         arg_conv.inner = (void*)(arg & (~1));
34744         arg_conv.is_owned = false;
34745         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34746         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
34747         return ret_conv;
34748 }
34749
34750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34751         LDKDataLossProtect orig_conv;
34752         orig_conv.inner = (void*)(orig & (~1));
34753         orig_conv.is_owned = false;
34754         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34755         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
34756         int64_t ret_ref = 0;
34757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34760         ret_ref = (uintptr_t)ret_var.inner;
34761         if (ret_var.is_owned) {
34762                 ret_ref |= 1;
34763         }
34764         return ret_ref;
34765 }
34766
34767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34768         LDKChannelReestablish this_obj_conv;
34769         this_obj_conv.inner = (void*)(this_obj & (~1));
34770         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34772         ChannelReestablish_free(this_obj_conv);
34773 }
34774
34775 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34776         LDKChannelReestablish this_ptr_conv;
34777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34778         this_ptr_conv.is_owned = false;
34779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34780         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34781         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
34782         return ret_arr;
34783 }
34784
34785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34786         LDKChannelReestablish this_ptr_conv;
34787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34788         this_ptr_conv.is_owned = false;
34789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34790         LDKThirtyTwoBytes val_ref;
34791         CHECK((*env)->GetArrayLength(env, val) == 32);
34792         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34793         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
34794 }
34795
34796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
34797         LDKChannelReestablish this_ptr_conv;
34798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34799         this_ptr_conv.is_owned = false;
34800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34801         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
34802         return ret_conv;
34803 }
34804
34805 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) {
34806         LDKChannelReestablish this_ptr_conv;
34807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34808         this_ptr_conv.is_owned = false;
34809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34810         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
34811 }
34812
34813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
34814         LDKChannelReestablish this_ptr_conv;
34815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34816         this_ptr_conv.is_owned = false;
34817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34818         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
34819         return ret_conv;
34820 }
34821
34822 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) {
34823         LDKChannelReestablish this_ptr_conv;
34824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34825         this_ptr_conv.is_owned = false;
34826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34827         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
34828 }
34829
34830 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
34831         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
34832 int64_t ret_ref = 0;
34833 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34834 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34835 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34836 ret_ref = (uintptr_t)ret_var.inner;
34837 if (ret_var.is_owned) {
34838         ret_ref |= 1;
34839 }
34840         return ret_ref;
34841 }
34842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34843         LDKChannelReestablish arg_conv;
34844         arg_conv.inner = (void*)(arg & (~1));
34845         arg_conv.is_owned = false;
34846         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34847         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
34848         return ret_conv;
34849 }
34850
34851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34852         LDKChannelReestablish orig_conv;
34853         orig_conv.inner = (void*)(orig & (~1));
34854         orig_conv.is_owned = false;
34855         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34856         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
34857         int64_t ret_ref = 0;
34858         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34859         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34860         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34861         ret_ref = (uintptr_t)ret_var.inner;
34862         if (ret_var.is_owned) {
34863                 ret_ref |= 1;
34864         }
34865         return ret_ref;
34866 }
34867
34868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34869         LDKAnnouncementSignatures this_obj_conv;
34870         this_obj_conv.inner = (void*)(this_obj & (~1));
34871         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34873         AnnouncementSignatures_free(this_obj_conv);
34874 }
34875
34876 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34877         LDKAnnouncementSignatures this_ptr_conv;
34878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34879         this_ptr_conv.is_owned = false;
34880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34881         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34882         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
34883         return ret_arr;
34884 }
34885
34886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34887         LDKAnnouncementSignatures this_ptr_conv;
34888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34889         this_ptr_conv.is_owned = false;
34890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34891         LDKThirtyTwoBytes val_ref;
34892         CHECK((*env)->GetArrayLength(env, val) == 32);
34893         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34894         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
34895 }
34896
34897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34898         LDKAnnouncementSignatures this_ptr_conv;
34899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34900         this_ptr_conv.is_owned = false;
34901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34902         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
34903         return ret_conv;
34904 }
34905
34906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34907         LDKAnnouncementSignatures this_ptr_conv;
34908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34909         this_ptr_conv.is_owned = false;
34910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34911         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
34912 }
34913
34914 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34915         LDKAnnouncementSignatures this_ptr_conv;
34916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34917         this_ptr_conv.is_owned = false;
34918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34919         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34920         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
34921         return ret_arr;
34922 }
34923
34924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34925         LDKAnnouncementSignatures this_ptr_conv;
34926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34927         this_ptr_conv.is_owned = false;
34928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34929         LDKSignature val_ref;
34930         CHECK((*env)->GetArrayLength(env, val) == 64);
34931         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34932         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
34933 }
34934
34935 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34936         LDKAnnouncementSignatures this_ptr_conv;
34937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34938         this_ptr_conv.is_owned = false;
34939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34940         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34941         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
34942         return ret_arr;
34943 }
34944
34945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKSignature val_ref;
34951         CHECK((*env)->GetArrayLength(env, val) == 64);
34952         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34953         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
34954 }
34955
34956 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) {
34957         LDKThirtyTwoBytes channel_id_arg_ref;
34958         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34959         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34960         LDKSignature node_signature_arg_ref;
34961         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
34962         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
34963         LDKSignature bitcoin_signature_arg_ref;
34964         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
34965         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
34966         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
34967         int64_t ret_ref = 0;
34968         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34969         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34970         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34971         ret_ref = (uintptr_t)ret_var.inner;
34972         if (ret_var.is_owned) {
34973                 ret_ref |= 1;
34974         }
34975         return ret_ref;
34976 }
34977
34978 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
34979         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
34980 int64_t ret_ref = 0;
34981 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34982 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34983 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34984 ret_ref = (uintptr_t)ret_var.inner;
34985 if (ret_var.is_owned) {
34986         ret_ref |= 1;
34987 }
34988         return ret_ref;
34989 }
34990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34991         LDKAnnouncementSignatures arg_conv;
34992         arg_conv.inner = (void*)(arg & (~1));
34993         arg_conv.is_owned = false;
34994         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34995         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
34996         return ret_conv;
34997 }
34998
34999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35000         LDKAnnouncementSignatures orig_conv;
35001         orig_conv.inner = (void*)(orig & (~1));
35002         orig_conv.is_owned = false;
35003         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35004         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
35005         int64_t ret_ref = 0;
35006         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35007         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35009         ret_ref = (uintptr_t)ret_var.inner;
35010         if (ret_var.is_owned) {
35011                 ret_ref |= 1;
35012         }
35013         return ret_ref;
35014 }
35015
35016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35017         if ((this_ptr & 1) != 0) return;
35018         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35019         CHECK_ACCESS(this_ptr_ptr);
35020         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
35021         FREE((void*)this_ptr);
35022         NetAddress_free(this_ptr_conv);
35023 }
35024
35025 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
35026         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35027         *ret_copy = NetAddress_clone(arg);
35028 int64_t ret_ref = (uintptr_t)ret_copy;
35029         return ret_ref;
35030 }
35031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35032         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
35033         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
35034         return ret_conv;
35035 }
35036
35037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35038         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
35039         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35040         *ret_copy = NetAddress_clone(orig_conv);
35041         int64_t ret_ref = (uintptr_t)ret_copy;
35042         return ret_ref;
35043 }
35044
35045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
35046         LDKFourBytes addr_ref;
35047         CHECK((*env)->GetArrayLength(env, addr) == 4);
35048         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
35049         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35050         *ret_copy = NetAddress_ipv4(addr_ref, port);
35051         int64_t ret_ref = (uintptr_t)ret_copy;
35052         return ret_ref;
35053 }
35054
35055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
35056         LDKSixteenBytes addr_ref;
35057         CHECK((*env)->GetArrayLength(env, addr) == 16);
35058         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
35059         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35060         *ret_copy = NetAddress_ipv6(addr_ref, port);
35061         int64_t ret_ref = (uintptr_t)ret_copy;
35062         return ret_ref;
35063 }
35064
35065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
35066         LDKTwelveBytes a_ref;
35067         CHECK((*env)->GetArrayLength(env, a) == 12);
35068         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
35069         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35070         *ret_copy = NetAddress_onion_v2(a_ref);
35071         int64_t ret_ref = (uintptr_t)ret_copy;
35072         return ret_ref;
35073 }
35074
35075 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) {
35076         LDKThirtyTwoBytes ed25519_pubkey_ref;
35077         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
35078         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
35079         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35080         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
35081         int64_t ret_ref = (uintptr_t)ret_copy;
35082         return ret_ref;
35083 }
35084
35085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1hostname(JNIEnv *env, jclass clz, int64_t hostname, int16_t port) {
35086         LDKHostname hostname_conv;
35087         hostname_conv.inner = (void*)(hostname & (~1));
35088         hostname_conv.is_owned = (hostname & 1) || (hostname == 0);
35089         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
35090         hostname_conv = Hostname_clone(&hostname_conv);
35091         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35092         *ret_copy = NetAddress_hostname(hostname_conv, port);
35093         int64_t ret_ref = (uintptr_t)ret_copy;
35094         return ret_ref;
35095 }
35096
35097 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
35098         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
35099         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
35100         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35101         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35102         CVec_u8Z_free(ret_var);
35103         return ret_arr;
35104 }
35105
35106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35107         LDKu8slice ser_ref;
35108         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35109         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35110         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
35111         *ret_conv = NetAddress_read(ser_ref);
35112         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35113         return (int64_t)ret_conv;
35114 }
35115
35116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35117         LDKUnsignedNodeAnnouncement this_obj_conv;
35118         this_obj_conv.inner = (void*)(this_obj & (~1));
35119         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35121         UnsignedNodeAnnouncement_free(this_obj_conv);
35122 }
35123
35124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
35125         LDKUnsignedNodeAnnouncement this_ptr_conv;
35126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35127         this_ptr_conv.is_owned = false;
35128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35129         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
35130         int64_t ret_ref = 0;
35131         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35132         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35134         ret_ref = (uintptr_t)ret_var.inner;
35135         if (ret_var.is_owned) {
35136                 ret_ref |= 1;
35137         }
35138         return ret_ref;
35139 }
35140
35141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35142         LDKUnsignedNodeAnnouncement this_ptr_conv;
35143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35144         this_ptr_conv.is_owned = false;
35145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35146         LDKNodeFeatures val_conv;
35147         val_conv.inner = (void*)(val & (~1));
35148         val_conv.is_owned = (val & 1) || (val == 0);
35149         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35150         val_conv = NodeFeatures_clone(&val_conv);
35151         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
35152 }
35153
35154 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
35155         LDKUnsignedNodeAnnouncement this_ptr_conv;
35156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35157         this_ptr_conv.is_owned = false;
35158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35159         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
35160         return ret_conv;
35161 }
35162
35163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
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         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
35169 }
35170
35171 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35172         LDKUnsignedNodeAnnouncement this_ptr_conv;
35173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35174         this_ptr_conv.is_owned = false;
35175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35176         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35177         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
35178         return ret_arr;
35179 }
35180
35181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35182         LDKUnsignedNodeAnnouncement this_ptr_conv;
35183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35184         this_ptr_conv.is_owned = false;
35185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35186         LDKPublicKey val_ref;
35187         CHECK((*env)->GetArrayLength(env, val) == 33);
35188         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35189         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
35190 }
35191
35192 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
35193         LDKUnsignedNodeAnnouncement this_ptr_conv;
35194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35195         this_ptr_conv.is_owned = false;
35196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35197         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
35198         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
35199         return ret_arr;
35200 }
35201
35202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKThreeBytes val_ref;
35208         CHECK((*env)->GetArrayLength(env, val) == 3);
35209         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
35210         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
35211 }
35212
35213 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
35214         LDKUnsignedNodeAnnouncement this_ptr_conv;
35215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35216         this_ptr_conv.is_owned = false;
35217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35218         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35219         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
35220         return ret_arr;
35221 }
35222
35223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35224         LDKUnsignedNodeAnnouncement this_ptr_conv;
35225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35226         this_ptr_conv.is_owned = false;
35227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35228         LDKThirtyTwoBytes val_ref;
35229         CHECK((*env)->GetArrayLength(env, val) == 32);
35230         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35231         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
35232 }
35233
35234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35235         LDKUnsignedNodeAnnouncement this_ptr_conv;
35236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35237         this_ptr_conv.is_owned = false;
35238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35239         LDKCVec_NetAddressZ val_constr;
35240         val_constr.datalen = (*env)->GetArrayLength(env, val);
35241         if (val_constr.datalen > 0)
35242                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
35243         else
35244                 val_constr.data = NULL;
35245         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35246         for (size_t m = 0; m < val_constr.datalen; m++) {
35247                 int64_t val_conv_12 = val_vals[m];
35248                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
35249                 CHECK_ACCESS(val_conv_12_ptr);
35250                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
35251                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
35252                 val_constr.data[m] = val_conv_12_conv;
35253         }
35254         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35255         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
35256 }
35257
35258 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
35259         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
35260 int64_t ret_ref = 0;
35261 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35262 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35263 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35264 ret_ref = (uintptr_t)ret_var.inner;
35265 if (ret_var.is_owned) {
35266         ret_ref |= 1;
35267 }
35268         return ret_ref;
35269 }
35270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35271         LDKUnsignedNodeAnnouncement arg_conv;
35272         arg_conv.inner = (void*)(arg & (~1));
35273         arg_conv.is_owned = false;
35274         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35275         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
35276         return ret_conv;
35277 }
35278
35279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35280         LDKUnsignedNodeAnnouncement orig_conv;
35281         orig_conv.inner = (void*)(orig & (~1));
35282         orig_conv.is_owned = false;
35283         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35284         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
35285         int64_t ret_ref = 0;
35286         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35287         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35289         ret_ref = (uintptr_t)ret_var.inner;
35290         if (ret_var.is_owned) {
35291                 ret_ref |= 1;
35292         }
35293         return ret_ref;
35294 }
35295
35296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35297         LDKNodeAnnouncement this_obj_conv;
35298         this_obj_conv.inner = (void*)(this_obj & (~1));
35299         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35301         NodeAnnouncement_free(this_obj_conv);
35302 }
35303
35304 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
35305         LDKNodeAnnouncement this_ptr_conv;
35306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35307         this_ptr_conv.is_owned = false;
35308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35309         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35310         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
35311         return ret_arr;
35312 }
35313
35314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35315         LDKNodeAnnouncement this_ptr_conv;
35316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35317         this_ptr_conv.is_owned = false;
35318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35319         LDKSignature val_ref;
35320         CHECK((*env)->GetArrayLength(env, val) == 64);
35321         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35322         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
35323 }
35324
35325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
35326         LDKNodeAnnouncement this_ptr_conv;
35327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35328         this_ptr_conv.is_owned = false;
35329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35330         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
35331         int64_t ret_ref = 0;
35332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35335         ret_ref = (uintptr_t)ret_var.inner;
35336         if (ret_var.is_owned) {
35337                 ret_ref |= 1;
35338         }
35339         return ret_ref;
35340 }
35341
35342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35343         LDKNodeAnnouncement this_ptr_conv;
35344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35345         this_ptr_conv.is_owned = false;
35346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35347         LDKUnsignedNodeAnnouncement val_conv;
35348         val_conv.inner = (void*)(val & (~1));
35349         val_conv.is_owned = (val & 1) || (val == 0);
35350         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35351         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
35352         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
35353 }
35354
35355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
35356         LDKSignature signature_arg_ref;
35357         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
35358         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
35359         LDKUnsignedNodeAnnouncement contents_arg_conv;
35360         contents_arg_conv.inner = (void*)(contents_arg & (~1));
35361         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
35362         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
35363         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
35364         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
35365         int64_t ret_ref = 0;
35366         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35367         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35369         ret_ref = (uintptr_t)ret_var.inner;
35370         if (ret_var.is_owned) {
35371                 ret_ref |= 1;
35372         }
35373         return ret_ref;
35374 }
35375
35376 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
35377         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
35378 int64_t ret_ref = 0;
35379 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35380 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35381 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35382 ret_ref = (uintptr_t)ret_var.inner;
35383 if (ret_var.is_owned) {
35384         ret_ref |= 1;
35385 }
35386         return ret_ref;
35387 }
35388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35389         LDKNodeAnnouncement arg_conv;
35390         arg_conv.inner = (void*)(arg & (~1));
35391         arg_conv.is_owned = false;
35392         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35393         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
35394         return ret_conv;
35395 }
35396
35397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35398         LDKNodeAnnouncement orig_conv;
35399         orig_conv.inner = (void*)(orig & (~1));
35400         orig_conv.is_owned = false;
35401         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35402         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
35403         int64_t ret_ref = 0;
35404         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35405         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35407         ret_ref = (uintptr_t)ret_var.inner;
35408         if (ret_var.is_owned) {
35409                 ret_ref |= 1;
35410         }
35411         return ret_ref;
35412 }
35413
35414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35415         LDKUnsignedChannelAnnouncement this_obj_conv;
35416         this_obj_conv.inner = (void*)(this_obj & (~1));
35417         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35419         UnsignedChannelAnnouncement_free(this_obj_conv);
35420 }
35421
35422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
35423         LDKUnsignedChannelAnnouncement this_ptr_conv;
35424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35425         this_ptr_conv.is_owned = false;
35426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35427         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
35428         int64_t ret_ref = 0;
35429         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35430         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35432         ret_ref = (uintptr_t)ret_var.inner;
35433         if (ret_var.is_owned) {
35434                 ret_ref |= 1;
35435         }
35436         return ret_ref;
35437 }
35438
35439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35440         LDKUnsignedChannelAnnouncement this_ptr_conv;
35441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35442         this_ptr_conv.is_owned = false;
35443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35444         LDKChannelFeatures val_conv;
35445         val_conv.inner = (void*)(val & (~1));
35446         val_conv.is_owned = (val & 1) || (val == 0);
35447         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35448         val_conv = ChannelFeatures_clone(&val_conv);
35449         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
35450 }
35451
35452 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35453         LDKUnsignedChannelAnnouncement this_ptr_conv;
35454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35455         this_ptr_conv.is_owned = false;
35456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35457         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35458         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
35459         return ret_arr;
35460 }
35461
35462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35463         LDKUnsignedChannelAnnouncement this_ptr_conv;
35464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35465         this_ptr_conv.is_owned = false;
35466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35467         LDKThirtyTwoBytes val_ref;
35468         CHECK((*env)->GetArrayLength(env, val) == 32);
35469         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35470         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
35471 }
35472
35473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35474         LDKUnsignedChannelAnnouncement this_ptr_conv;
35475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35476         this_ptr_conv.is_owned = false;
35477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35478         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
35479         return ret_conv;
35480 }
35481
35482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35483         LDKUnsignedChannelAnnouncement this_ptr_conv;
35484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35485         this_ptr_conv.is_owned = false;
35486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35487         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
35488 }
35489
35490 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
35491         LDKUnsignedChannelAnnouncement this_ptr_conv;
35492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35493         this_ptr_conv.is_owned = false;
35494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35495         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35496         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
35497         return ret_arr;
35498 }
35499
35500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35501         LDKUnsignedChannelAnnouncement this_ptr_conv;
35502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35503         this_ptr_conv.is_owned = false;
35504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35505         LDKPublicKey val_ref;
35506         CHECK((*env)->GetArrayLength(env, val) == 33);
35507         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35508         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
35509 }
35510
35511 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(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, 33);
35517         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
35518         return ret_arr;
35519 }
35520
35521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(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         LDKPublicKey val_ref;
35527         CHECK((*env)->GetArrayLength(env, val) == 33);
35528         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35529         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
35530 }
35531
35532 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(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         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35538         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
35539         return ret_arr;
35540 }
35541
35542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35543         LDKUnsignedChannelAnnouncement this_ptr_conv;
35544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35545         this_ptr_conv.is_owned = false;
35546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35547         LDKPublicKey val_ref;
35548         CHECK((*env)->GetArrayLength(env, val) == 33);
35549         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35550         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
35551 }
35552
35553 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
35554         LDKUnsignedChannelAnnouncement this_ptr_conv;
35555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35556         this_ptr_conv.is_owned = false;
35557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35558         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35559         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
35560         return ret_arr;
35561 }
35562
35563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35564         LDKUnsignedChannelAnnouncement this_ptr_conv;
35565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35566         this_ptr_conv.is_owned = false;
35567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35568         LDKPublicKey val_ref;
35569         CHECK((*env)->GetArrayLength(env, val) == 33);
35570         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35571         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
35572 }
35573
35574 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
35575         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
35576 int64_t ret_ref = 0;
35577 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35578 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35579 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35580 ret_ref = (uintptr_t)ret_var.inner;
35581 if (ret_var.is_owned) {
35582         ret_ref |= 1;
35583 }
35584         return ret_ref;
35585 }
35586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35587         LDKUnsignedChannelAnnouncement arg_conv;
35588         arg_conv.inner = (void*)(arg & (~1));
35589         arg_conv.is_owned = false;
35590         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35591         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
35592         return ret_conv;
35593 }
35594
35595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35596         LDKUnsignedChannelAnnouncement orig_conv;
35597         orig_conv.inner = (void*)(orig & (~1));
35598         orig_conv.is_owned = false;
35599         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35600         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
35601         int64_t ret_ref = 0;
35602         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35603         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35605         ret_ref = (uintptr_t)ret_var.inner;
35606         if (ret_var.is_owned) {
35607                 ret_ref |= 1;
35608         }
35609         return ret_ref;
35610 }
35611
35612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35613         LDKChannelAnnouncement this_obj_conv;
35614         this_obj_conv.inner = (void*)(this_obj & (~1));
35615         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35617         ChannelAnnouncement_free(this_obj_conv);
35618 }
35619
35620 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
35621         LDKChannelAnnouncement this_ptr_conv;
35622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35623         this_ptr_conv.is_owned = false;
35624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35625         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35626         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
35627         return ret_arr;
35628 }
35629
35630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35631         LDKChannelAnnouncement this_ptr_conv;
35632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35633         this_ptr_conv.is_owned = false;
35634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35635         LDKSignature val_ref;
35636         CHECK((*env)->GetArrayLength(env, val) == 64);
35637         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35638         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
35639 }
35640
35641 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
35642         LDKChannelAnnouncement this_ptr_conv;
35643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35644         this_ptr_conv.is_owned = false;
35645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35646         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35647         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
35648         return ret_arr;
35649 }
35650
35651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35652         LDKChannelAnnouncement this_ptr_conv;
35653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35654         this_ptr_conv.is_owned = false;
35655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35656         LDKSignature val_ref;
35657         CHECK((*env)->GetArrayLength(env, val) == 64);
35658         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35659         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
35660 }
35661
35662 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
35663         LDKChannelAnnouncement this_ptr_conv;
35664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35665         this_ptr_conv.is_owned = false;
35666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35667         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35668         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
35669         return ret_arr;
35670 }
35671
35672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35673         LDKChannelAnnouncement this_ptr_conv;
35674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35675         this_ptr_conv.is_owned = false;
35676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35677         LDKSignature val_ref;
35678         CHECK((*env)->GetArrayLength(env, val) == 64);
35679         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35680         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
35681 }
35682
35683 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
35684         LDKChannelAnnouncement this_ptr_conv;
35685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35686         this_ptr_conv.is_owned = false;
35687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35688         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35689         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
35690         return ret_arr;
35691 }
35692
35693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35694         LDKChannelAnnouncement this_ptr_conv;
35695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35696         this_ptr_conv.is_owned = false;
35697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35698         LDKSignature val_ref;
35699         CHECK((*env)->GetArrayLength(env, val) == 64);
35700         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35701         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
35702 }
35703
35704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
35705         LDKChannelAnnouncement this_ptr_conv;
35706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35707         this_ptr_conv.is_owned = false;
35708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35709         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
35710         int64_t ret_ref = 0;
35711         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35712         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35714         ret_ref = (uintptr_t)ret_var.inner;
35715         if (ret_var.is_owned) {
35716                 ret_ref |= 1;
35717         }
35718         return ret_ref;
35719 }
35720
35721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
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         LDKUnsignedChannelAnnouncement val_conv;
35727         val_conv.inner = (void*)(val & (~1));
35728         val_conv.is_owned = (val & 1) || (val == 0);
35729         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35730         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
35731         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
35732 }
35733
35734 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) {
35735         LDKSignature node_signature_1_arg_ref;
35736         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
35737         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
35738         LDKSignature node_signature_2_arg_ref;
35739         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
35740         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
35741         LDKSignature bitcoin_signature_1_arg_ref;
35742         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
35743         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
35744         LDKSignature bitcoin_signature_2_arg_ref;
35745         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
35746         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
35747         LDKUnsignedChannelAnnouncement contents_arg_conv;
35748         contents_arg_conv.inner = (void*)(contents_arg & (~1));
35749         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
35750         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
35751         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
35752         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);
35753         int64_t ret_ref = 0;
35754         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35755         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35757         ret_ref = (uintptr_t)ret_var.inner;
35758         if (ret_var.is_owned) {
35759                 ret_ref |= 1;
35760         }
35761         return ret_ref;
35762 }
35763
35764 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
35765         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
35766 int64_t ret_ref = 0;
35767 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35768 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35769 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35770 ret_ref = (uintptr_t)ret_var.inner;
35771 if (ret_var.is_owned) {
35772         ret_ref |= 1;
35773 }
35774         return ret_ref;
35775 }
35776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35777         LDKChannelAnnouncement arg_conv;
35778         arg_conv.inner = (void*)(arg & (~1));
35779         arg_conv.is_owned = false;
35780         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35781         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
35782         return ret_conv;
35783 }
35784
35785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35786         LDKChannelAnnouncement orig_conv;
35787         orig_conv.inner = (void*)(orig & (~1));
35788         orig_conv.is_owned = false;
35789         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35790         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
35791         int64_t ret_ref = 0;
35792         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35793         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35795         ret_ref = (uintptr_t)ret_var.inner;
35796         if (ret_var.is_owned) {
35797                 ret_ref |= 1;
35798         }
35799         return ret_ref;
35800 }
35801
35802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35803         LDKUnsignedChannelUpdate this_obj_conv;
35804         this_obj_conv.inner = (void*)(this_obj & (~1));
35805         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35807         UnsignedChannelUpdate_free(this_obj_conv);
35808 }
35809
35810 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35811         LDKUnsignedChannelUpdate this_ptr_conv;
35812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35813         this_ptr_conv.is_owned = false;
35814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35815         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35816         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
35817         return ret_arr;
35818 }
35819
35820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35821         LDKUnsignedChannelUpdate this_ptr_conv;
35822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35823         this_ptr_conv.is_owned = false;
35824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35825         LDKThirtyTwoBytes val_ref;
35826         CHECK((*env)->GetArrayLength(env, val) == 32);
35827         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35828         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
35829 }
35830
35831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35832         LDKUnsignedChannelUpdate this_ptr_conv;
35833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35834         this_ptr_conv.is_owned = false;
35835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35836         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
35837         return ret_conv;
35838 }
35839
35840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35841         LDKUnsignedChannelUpdate this_ptr_conv;
35842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35843         this_ptr_conv.is_owned = false;
35844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35845         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
35846 }
35847
35848 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
35849         LDKUnsignedChannelUpdate this_ptr_conv;
35850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35851         this_ptr_conv.is_owned = false;
35852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35853         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
35854         return ret_conv;
35855 }
35856
35857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35858         LDKUnsignedChannelUpdate this_ptr_conv;
35859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35860         this_ptr_conv.is_owned = false;
35861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35862         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
35863 }
35864
35865 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
35866         LDKUnsignedChannelUpdate this_ptr_conv;
35867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35868         this_ptr_conv.is_owned = false;
35869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35870         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
35871         return ret_conv;
35872 }
35873
35874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
35875         LDKUnsignedChannelUpdate this_ptr_conv;
35876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35877         this_ptr_conv.is_owned = false;
35878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35879         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
35880 }
35881
35882 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
35883         LDKUnsignedChannelUpdate this_ptr_conv;
35884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35885         this_ptr_conv.is_owned = false;
35886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35887         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
35888         return ret_conv;
35889 }
35890
35891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35892         LDKUnsignedChannelUpdate this_ptr_conv;
35893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35894         this_ptr_conv.is_owned = false;
35895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35896         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
35897 }
35898
35899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
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         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
35905         return ret_conv;
35906 }
35907
35908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35909         LDKUnsignedChannelUpdate this_ptr_conv;
35910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35911         this_ptr_conv.is_owned = false;
35912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35913         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
35914 }
35915
35916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
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         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
35922         return ret_conv;
35923 }
35924
35925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35926         LDKUnsignedChannelUpdate this_ptr_conv;
35927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35928         this_ptr_conv.is_owned = false;
35929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35930         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
35931 }
35932
35933 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
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         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
35939         return ret_conv;
35940 }
35941
35942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35943         LDKUnsignedChannelUpdate this_ptr_conv;
35944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35945         this_ptr_conv.is_owned = false;
35946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35947         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
35948 }
35949
35950 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
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         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
35956         return ret_conv;
35957 }
35958
35959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35960         LDKUnsignedChannelUpdate this_ptr_conv;
35961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35962         this_ptr_conv.is_owned = false;
35963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35964         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
35965 }
35966
35967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKCVec_u8Z val_ref;
35973         val_ref.datalen = (*env)->GetArrayLength(env, val);
35974         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
35975         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
35976         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
35977 }
35978
35979 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) {
35980         LDKThirtyTwoBytes chain_hash_arg_ref;
35981         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35982         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35983         LDKCVec_u8Z excess_data_arg_ref;
35984         excess_data_arg_ref.datalen = (*env)->GetArrayLength(env, excess_data_arg);
35985         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
35986         (*env)->GetByteArrayRegion(env, excess_data_arg, 0, excess_data_arg_ref.datalen, excess_data_arg_ref.data);
35987         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);
35988         int64_t ret_ref = 0;
35989         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35990         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35991         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35992         ret_ref = (uintptr_t)ret_var.inner;
35993         if (ret_var.is_owned) {
35994                 ret_ref |= 1;
35995         }
35996         return ret_ref;
35997 }
35998
35999 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
36000         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
36001 int64_t ret_ref = 0;
36002 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36003 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36004 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36005 ret_ref = (uintptr_t)ret_var.inner;
36006 if (ret_var.is_owned) {
36007         ret_ref |= 1;
36008 }
36009         return ret_ref;
36010 }
36011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36012         LDKUnsignedChannelUpdate arg_conv;
36013         arg_conv.inner = (void*)(arg & (~1));
36014         arg_conv.is_owned = false;
36015         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36016         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
36017         return ret_conv;
36018 }
36019
36020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36021         LDKUnsignedChannelUpdate orig_conv;
36022         orig_conv.inner = (void*)(orig & (~1));
36023         orig_conv.is_owned = false;
36024         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36025         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
36026         int64_t ret_ref = 0;
36027         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36028         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36030         ret_ref = (uintptr_t)ret_var.inner;
36031         if (ret_var.is_owned) {
36032                 ret_ref |= 1;
36033         }
36034         return ret_ref;
36035 }
36036
36037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36038         LDKChannelUpdate this_obj_conv;
36039         this_obj_conv.inner = (void*)(this_obj & (~1));
36040         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36042         ChannelUpdate_free(this_obj_conv);
36043 }
36044
36045 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36046         LDKChannelUpdate this_ptr_conv;
36047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36048         this_ptr_conv.is_owned = false;
36049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36050         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36051         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
36052         return ret_arr;
36053 }
36054
36055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36056         LDKChannelUpdate this_ptr_conv;
36057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36058         this_ptr_conv.is_owned = false;
36059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36060         LDKSignature val_ref;
36061         CHECK((*env)->GetArrayLength(env, val) == 64);
36062         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36063         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
36064 }
36065
36066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
36067         LDKChannelUpdate this_ptr_conv;
36068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36069         this_ptr_conv.is_owned = false;
36070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36071         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
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
36083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36084         LDKChannelUpdate this_ptr_conv;
36085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36086         this_ptr_conv.is_owned = false;
36087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36088         LDKUnsignedChannelUpdate val_conv;
36089         val_conv.inner = (void*)(val & (~1));
36090         val_conv.is_owned = (val & 1) || (val == 0);
36091         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36092         val_conv = UnsignedChannelUpdate_clone(&val_conv);
36093         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
36094 }
36095
36096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
36097         LDKSignature signature_arg_ref;
36098         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36099         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36100         LDKUnsignedChannelUpdate contents_arg_conv;
36101         contents_arg_conv.inner = (void*)(contents_arg & (~1));
36102         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
36103         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
36104         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
36105         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
36106         int64_t ret_ref = 0;
36107         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36108         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36110         ret_ref = (uintptr_t)ret_var.inner;
36111         if (ret_var.is_owned) {
36112                 ret_ref |= 1;
36113         }
36114         return ret_ref;
36115 }
36116
36117 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
36118         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
36119 int64_t ret_ref = 0;
36120 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36121 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36122 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36123 ret_ref = (uintptr_t)ret_var.inner;
36124 if (ret_var.is_owned) {
36125         ret_ref |= 1;
36126 }
36127         return ret_ref;
36128 }
36129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36130         LDKChannelUpdate arg_conv;
36131         arg_conv.inner = (void*)(arg & (~1));
36132         arg_conv.is_owned = false;
36133         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36134         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
36135         return ret_conv;
36136 }
36137
36138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36139         LDKChannelUpdate orig_conv;
36140         orig_conv.inner = (void*)(orig & (~1));
36141         orig_conv.is_owned = false;
36142         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36143         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
36144         int64_t ret_ref = 0;
36145         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36146         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36148         ret_ref = (uintptr_t)ret_var.inner;
36149         if (ret_var.is_owned) {
36150                 ret_ref |= 1;
36151         }
36152         return ret_ref;
36153 }
36154
36155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36156         LDKQueryChannelRange this_obj_conv;
36157         this_obj_conv.inner = (void*)(this_obj & (~1));
36158         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36160         QueryChannelRange_free(this_obj_conv);
36161 }
36162
36163 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36164         LDKQueryChannelRange this_ptr_conv;
36165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36166         this_ptr_conv.is_owned = false;
36167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36168         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36169         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
36170         return ret_arr;
36171 }
36172
36173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36174         LDKQueryChannelRange this_ptr_conv;
36175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36176         this_ptr_conv.is_owned = false;
36177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36178         LDKThirtyTwoBytes val_ref;
36179         CHECK((*env)->GetArrayLength(env, val) == 32);
36180         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36181         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
36182 }
36183
36184 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
36185         LDKQueryChannelRange this_ptr_conv;
36186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36187         this_ptr_conv.is_owned = false;
36188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36189         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
36190         return ret_conv;
36191 }
36192
36193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36194         LDKQueryChannelRange this_ptr_conv;
36195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36196         this_ptr_conv.is_owned = false;
36197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36198         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
36199 }
36200
36201 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
36202         LDKQueryChannelRange this_ptr_conv;
36203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36204         this_ptr_conv.is_owned = false;
36205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36206         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
36207         return ret_conv;
36208 }
36209
36210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36211         LDKQueryChannelRange this_ptr_conv;
36212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36213         this_ptr_conv.is_owned = false;
36214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36215         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
36216 }
36217
36218 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) {
36219         LDKThirtyTwoBytes chain_hash_arg_ref;
36220         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36221         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36222         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
36223         int64_t ret_ref = 0;
36224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36227         ret_ref = (uintptr_t)ret_var.inner;
36228         if (ret_var.is_owned) {
36229                 ret_ref |= 1;
36230         }
36231         return ret_ref;
36232 }
36233
36234 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
36235         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
36236 int64_t ret_ref = 0;
36237 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36238 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36239 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36240 ret_ref = (uintptr_t)ret_var.inner;
36241 if (ret_var.is_owned) {
36242         ret_ref |= 1;
36243 }
36244         return ret_ref;
36245 }
36246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36247         LDKQueryChannelRange arg_conv;
36248         arg_conv.inner = (void*)(arg & (~1));
36249         arg_conv.is_owned = false;
36250         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36251         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
36252         return ret_conv;
36253 }
36254
36255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36256         LDKQueryChannelRange orig_conv;
36257         orig_conv.inner = (void*)(orig & (~1));
36258         orig_conv.is_owned = false;
36259         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36260         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
36261         int64_t ret_ref = 0;
36262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36265         ret_ref = (uintptr_t)ret_var.inner;
36266         if (ret_var.is_owned) {
36267                 ret_ref |= 1;
36268         }
36269         return ret_ref;
36270 }
36271
36272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36273         LDKReplyChannelRange this_obj_conv;
36274         this_obj_conv.inner = (void*)(this_obj & (~1));
36275         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36277         ReplyChannelRange_free(this_obj_conv);
36278 }
36279
36280 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36281         LDKReplyChannelRange this_ptr_conv;
36282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36283         this_ptr_conv.is_owned = false;
36284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36285         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36286         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
36287         return ret_arr;
36288 }
36289
36290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36291         LDKReplyChannelRange this_ptr_conv;
36292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36293         this_ptr_conv.is_owned = false;
36294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36295         LDKThirtyTwoBytes val_ref;
36296         CHECK((*env)->GetArrayLength(env, val) == 32);
36297         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36298         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
36299 }
36300
36301 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
36302         LDKReplyChannelRange this_ptr_conv;
36303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36304         this_ptr_conv.is_owned = false;
36305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36306         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
36307         return ret_conv;
36308 }
36309
36310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36311         LDKReplyChannelRange this_ptr_conv;
36312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36313         this_ptr_conv.is_owned = false;
36314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36315         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
36316 }
36317
36318 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
36319         LDKReplyChannelRange this_ptr_conv;
36320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36321         this_ptr_conv.is_owned = false;
36322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36323         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
36324         return ret_conv;
36325 }
36326
36327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36328         LDKReplyChannelRange this_ptr_conv;
36329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36330         this_ptr_conv.is_owned = false;
36331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36332         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
36333 }
36334
36335 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
36336         LDKReplyChannelRange this_ptr_conv;
36337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36338         this_ptr_conv.is_owned = false;
36339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36340         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
36341         return ret_conv;
36342 }
36343
36344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
36345         LDKReplyChannelRange this_ptr_conv;
36346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36347         this_ptr_conv.is_owned = false;
36348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36349         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
36350 }
36351
36352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36353         LDKReplyChannelRange this_ptr_conv;
36354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36355         this_ptr_conv.is_owned = false;
36356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36357         LDKCVec_u64Z val_constr;
36358         val_constr.datalen = (*env)->GetArrayLength(env, val);
36359         if (val_constr.datalen > 0)
36360                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36361         else
36362                 val_constr.data = NULL;
36363         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36364         for (size_t g = 0; g < val_constr.datalen; g++) {
36365                 int64_t val_conv_6 = val_vals[g];
36366                 val_constr.data[g] = val_conv_6;
36367         }
36368         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36369         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
36370 }
36371
36372 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) {
36373         LDKThirtyTwoBytes chain_hash_arg_ref;
36374         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36375         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36376         LDKCVec_u64Z short_channel_ids_arg_constr;
36377         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
36378         if (short_channel_ids_arg_constr.datalen > 0)
36379                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36380         else
36381                 short_channel_ids_arg_constr.data = NULL;
36382         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
36383         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
36384                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
36385                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
36386         }
36387         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
36388         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
36389         int64_t ret_ref = 0;
36390         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36391         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36393         ret_ref = (uintptr_t)ret_var.inner;
36394         if (ret_var.is_owned) {
36395                 ret_ref |= 1;
36396         }
36397         return ret_ref;
36398 }
36399
36400 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
36401         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
36402 int64_t ret_ref = 0;
36403 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36404 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36405 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36406 ret_ref = (uintptr_t)ret_var.inner;
36407 if (ret_var.is_owned) {
36408         ret_ref |= 1;
36409 }
36410         return ret_ref;
36411 }
36412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36413         LDKReplyChannelRange arg_conv;
36414         arg_conv.inner = (void*)(arg & (~1));
36415         arg_conv.is_owned = false;
36416         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36417         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
36418         return ret_conv;
36419 }
36420
36421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36422         LDKReplyChannelRange orig_conv;
36423         orig_conv.inner = (void*)(orig & (~1));
36424         orig_conv.is_owned = false;
36425         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36426         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
36427         int64_t ret_ref = 0;
36428         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36429         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36431         ret_ref = (uintptr_t)ret_var.inner;
36432         if (ret_var.is_owned) {
36433                 ret_ref |= 1;
36434         }
36435         return ret_ref;
36436 }
36437
36438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36439         LDKQueryShortChannelIds this_obj_conv;
36440         this_obj_conv.inner = (void*)(this_obj & (~1));
36441         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36443         QueryShortChannelIds_free(this_obj_conv);
36444 }
36445
36446 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36447         LDKQueryShortChannelIds this_ptr_conv;
36448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36449         this_ptr_conv.is_owned = false;
36450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36451         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36452         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
36453         return ret_arr;
36454 }
36455
36456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36457         LDKQueryShortChannelIds this_ptr_conv;
36458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36459         this_ptr_conv.is_owned = false;
36460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36461         LDKThirtyTwoBytes val_ref;
36462         CHECK((*env)->GetArrayLength(env, val) == 32);
36463         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36464         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
36465 }
36466
36467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36468         LDKQueryShortChannelIds this_ptr_conv;
36469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36470         this_ptr_conv.is_owned = false;
36471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36472         LDKCVec_u64Z val_constr;
36473         val_constr.datalen = (*env)->GetArrayLength(env, val);
36474         if (val_constr.datalen > 0)
36475                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36476         else
36477                 val_constr.data = NULL;
36478         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36479         for (size_t g = 0; g < val_constr.datalen; g++) {
36480                 int64_t val_conv_6 = val_vals[g];
36481                 val_constr.data[g] = val_conv_6;
36482         }
36483         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36484         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
36485 }
36486
36487 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) {
36488         LDKThirtyTwoBytes chain_hash_arg_ref;
36489         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36490         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36491         LDKCVec_u64Z short_channel_ids_arg_constr;
36492         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
36493         if (short_channel_ids_arg_constr.datalen > 0)
36494                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36495         else
36496                 short_channel_ids_arg_constr.data = NULL;
36497         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
36498         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
36499                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
36500                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
36501         }
36502         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
36503         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
36504         int64_t ret_ref = 0;
36505         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36506         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36508         ret_ref = (uintptr_t)ret_var.inner;
36509         if (ret_var.is_owned) {
36510                 ret_ref |= 1;
36511         }
36512         return ret_ref;
36513 }
36514
36515 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
36516         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
36517 int64_t ret_ref = 0;
36518 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36519 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36520 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36521 ret_ref = (uintptr_t)ret_var.inner;
36522 if (ret_var.is_owned) {
36523         ret_ref |= 1;
36524 }
36525         return ret_ref;
36526 }
36527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36528         LDKQueryShortChannelIds arg_conv;
36529         arg_conv.inner = (void*)(arg & (~1));
36530         arg_conv.is_owned = false;
36531         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36532         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
36533         return ret_conv;
36534 }
36535
36536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36537         LDKQueryShortChannelIds orig_conv;
36538         orig_conv.inner = (void*)(orig & (~1));
36539         orig_conv.is_owned = false;
36540         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36541         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
36542         int64_t ret_ref = 0;
36543         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36544         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36546         ret_ref = (uintptr_t)ret_var.inner;
36547         if (ret_var.is_owned) {
36548                 ret_ref |= 1;
36549         }
36550         return ret_ref;
36551 }
36552
36553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36554         LDKReplyShortChannelIdsEnd this_obj_conv;
36555         this_obj_conv.inner = (void*)(this_obj & (~1));
36556         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36558         ReplyShortChannelIdsEnd_free(this_obj_conv);
36559 }
36560
36561 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36562         LDKReplyShortChannelIdsEnd this_ptr_conv;
36563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36564         this_ptr_conv.is_owned = false;
36565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36566         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36567         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
36568         return ret_arr;
36569 }
36570
36571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36572         LDKReplyShortChannelIdsEnd this_ptr_conv;
36573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36574         this_ptr_conv.is_owned = false;
36575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36576         LDKThirtyTwoBytes val_ref;
36577         CHECK((*env)->GetArrayLength(env, val) == 32);
36578         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36579         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
36580 }
36581
36582 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
36583         LDKReplyShortChannelIdsEnd this_ptr_conv;
36584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36585         this_ptr_conv.is_owned = false;
36586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36587         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
36588         return ret_conv;
36589 }
36590
36591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
36592         LDKReplyShortChannelIdsEnd this_ptr_conv;
36593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36594         this_ptr_conv.is_owned = false;
36595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36596         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
36597 }
36598
36599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
36600         LDKThirtyTwoBytes chain_hash_arg_ref;
36601         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36602         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36603         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
36604         int64_t ret_ref = 0;
36605         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36606         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36608         ret_ref = (uintptr_t)ret_var.inner;
36609         if (ret_var.is_owned) {
36610                 ret_ref |= 1;
36611         }
36612         return ret_ref;
36613 }
36614
36615 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
36616         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
36617 int64_t ret_ref = 0;
36618 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36619 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36620 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36621 ret_ref = (uintptr_t)ret_var.inner;
36622 if (ret_var.is_owned) {
36623         ret_ref |= 1;
36624 }
36625         return ret_ref;
36626 }
36627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36628         LDKReplyShortChannelIdsEnd arg_conv;
36629         arg_conv.inner = (void*)(arg & (~1));
36630         arg_conv.is_owned = false;
36631         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36632         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
36633         return ret_conv;
36634 }
36635
36636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36637         LDKReplyShortChannelIdsEnd orig_conv;
36638         orig_conv.inner = (void*)(orig & (~1));
36639         orig_conv.is_owned = false;
36640         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36641         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
36642         int64_t ret_ref = 0;
36643         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36644         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36646         ret_ref = (uintptr_t)ret_var.inner;
36647         if (ret_var.is_owned) {
36648                 ret_ref |= 1;
36649         }
36650         return ret_ref;
36651 }
36652
36653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36654         LDKGossipTimestampFilter this_obj_conv;
36655         this_obj_conv.inner = (void*)(this_obj & (~1));
36656         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36658         GossipTimestampFilter_free(this_obj_conv);
36659 }
36660
36661 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36662         LDKGossipTimestampFilter this_ptr_conv;
36663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36664         this_ptr_conv.is_owned = false;
36665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36666         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36667         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
36668         return ret_arr;
36669 }
36670
36671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36672         LDKGossipTimestampFilter this_ptr_conv;
36673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36674         this_ptr_conv.is_owned = false;
36675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36676         LDKThirtyTwoBytes val_ref;
36677         CHECK((*env)->GetArrayLength(env, val) == 32);
36678         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36679         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
36680 }
36681
36682 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
36683         LDKGossipTimestampFilter this_ptr_conv;
36684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36685         this_ptr_conv.is_owned = false;
36686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36687         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
36688         return ret_conv;
36689 }
36690
36691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36692         LDKGossipTimestampFilter this_ptr_conv;
36693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36694         this_ptr_conv.is_owned = false;
36695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36696         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
36697 }
36698
36699 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
36700         LDKGossipTimestampFilter this_ptr_conv;
36701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36702         this_ptr_conv.is_owned = false;
36703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36704         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
36705         return ret_conv;
36706 }
36707
36708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36709         LDKGossipTimestampFilter this_ptr_conv;
36710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36711         this_ptr_conv.is_owned = false;
36712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36713         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
36714 }
36715
36716 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) {
36717         LDKThirtyTwoBytes chain_hash_arg_ref;
36718         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36719         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36720         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
36721         int64_t ret_ref = 0;
36722         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36723         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36725         ret_ref = (uintptr_t)ret_var.inner;
36726         if (ret_var.is_owned) {
36727                 ret_ref |= 1;
36728         }
36729         return ret_ref;
36730 }
36731
36732 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
36733         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
36734 int64_t ret_ref = 0;
36735 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36736 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36737 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36738 ret_ref = (uintptr_t)ret_var.inner;
36739 if (ret_var.is_owned) {
36740         ret_ref |= 1;
36741 }
36742         return ret_ref;
36743 }
36744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36745         LDKGossipTimestampFilter arg_conv;
36746         arg_conv.inner = (void*)(arg & (~1));
36747         arg_conv.is_owned = false;
36748         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36749         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
36750         return ret_conv;
36751 }
36752
36753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36754         LDKGossipTimestampFilter orig_conv;
36755         orig_conv.inner = (void*)(orig & (~1));
36756         orig_conv.is_owned = false;
36757         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36758         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
36759         int64_t ret_ref = 0;
36760         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36761         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36763         ret_ref = (uintptr_t)ret_var.inner;
36764         if (ret_var.is_owned) {
36765                 ret_ref |= 1;
36766         }
36767         return ret_ref;
36768 }
36769
36770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36771         if ((this_ptr & 1) != 0) return;
36772         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36773         CHECK_ACCESS(this_ptr_ptr);
36774         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
36775         FREE((void*)this_ptr);
36776         ErrorAction_free(this_ptr_conv);
36777 }
36778
36779 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
36780         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36781         *ret_copy = ErrorAction_clone(arg);
36782 int64_t ret_ref = (uintptr_t)ret_copy;
36783         return ret_ref;
36784 }
36785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36786         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
36787         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
36788         return ret_conv;
36789 }
36790
36791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36792         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
36793         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36794         *ret_copy = ErrorAction_clone(orig_conv);
36795         int64_t ret_ref = (uintptr_t)ret_copy;
36796         return ret_ref;
36797 }
36798
36799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
36800         LDKErrorMessage msg_conv;
36801         msg_conv.inner = (void*)(msg & (~1));
36802         msg_conv.is_owned = (msg & 1) || (msg == 0);
36803         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36804         msg_conv = ErrorMessage_clone(&msg_conv);
36805         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36806         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
36807         int64_t ret_ref = (uintptr_t)ret_copy;
36808         return ret_ref;
36809 }
36810
36811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
36812         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36813         *ret_copy = ErrorAction_ignore_error();
36814         int64_t ret_ref = (uintptr_t)ret_copy;
36815         return ret_ref;
36816 }
36817
36818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
36819         LDKLevel a_conv = LDKLevel_from_java(env, a);
36820         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36821         *ret_copy = ErrorAction_ignore_and_log(a_conv);
36822         int64_t ret_ref = (uintptr_t)ret_copy;
36823         return ret_ref;
36824 }
36825
36826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
36827         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36828         *ret_copy = ErrorAction_ignore_duplicate_gossip();
36829         int64_t ret_ref = (uintptr_t)ret_copy;
36830         return ret_ref;
36831 }
36832
36833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
36834         LDKErrorMessage msg_conv;
36835         msg_conv.inner = (void*)(msg & (~1));
36836         msg_conv.is_owned = (msg & 1) || (msg == 0);
36837         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36838         msg_conv = ErrorMessage_clone(&msg_conv);
36839         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36840         *ret_copy = ErrorAction_send_error_message(msg_conv);
36841         int64_t ret_ref = (uintptr_t)ret_copy;
36842         return ret_ref;
36843 }
36844
36845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
36846         LDKWarningMessage msg_conv;
36847         msg_conv.inner = (void*)(msg & (~1));
36848         msg_conv.is_owned = (msg & 1) || (msg == 0);
36849         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36850         msg_conv = WarningMessage_clone(&msg_conv);
36851         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
36852         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36853         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
36854         int64_t ret_ref = (uintptr_t)ret_copy;
36855         return ret_ref;
36856 }
36857
36858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36859         LDKLightningError this_obj_conv;
36860         this_obj_conv.inner = (void*)(this_obj & (~1));
36861         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36863         LightningError_free(this_obj_conv);
36864 }
36865
36866 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
36867         LDKLightningError this_ptr_conv;
36868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36869         this_ptr_conv.is_owned = false;
36870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36871         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
36872         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
36873         Str_free(ret_str);
36874         return ret_conv;
36875 }
36876
36877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
36878         LDKLightningError this_ptr_conv;
36879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36880         this_ptr_conv.is_owned = false;
36881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36882         LDKStr val_conv = java_to_owned_str(env, val);
36883         LightningError_set_err(&this_ptr_conv, val_conv);
36884 }
36885
36886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
36887         LDKLightningError this_ptr_conv;
36888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36889         this_ptr_conv.is_owned = false;
36890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36891         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36892         *ret_copy = LightningError_get_action(&this_ptr_conv);
36893         int64_t ret_ref = (uintptr_t)ret_copy;
36894         return ret_ref;
36895 }
36896
36897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36898         LDKLightningError this_ptr_conv;
36899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36900         this_ptr_conv.is_owned = false;
36901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36902         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36903         CHECK_ACCESS(val_ptr);
36904         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
36905         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
36906         LightningError_set_action(&this_ptr_conv, val_conv);
36907 }
36908
36909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
36910         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
36911         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
36912         CHECK_ACCESS(action_arg_ptr);
36913         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
36914         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
36915         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
36916         int64_t ret_ref = 0;
36917         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36918         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36919         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36920         ret_ref = (uintptr_t)ret_var.inner;
36921         if (ret_var.is_owned) {
36922                 ret_ref |= 1;
36923         }
36924         return ret_ref;
36925 }
36926
36927 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
36928         LDKLightningError ret_var = LightningError_clone(arg);
36929 int64_t ret_ref = 0;
36930 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36931 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36932 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36933 ret_ref = (uintptr_t)ret_var.inner;
36934 if (ret_var.is_owned) {
36935         ret_ref |= 1;
36936 }
36937         return ret_ref;
36938 }
36939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36940         LDKLightningError arg_conv;
36941         arg_conv.inner = (void*)(arg & (~1));
36942         arg_conv.is_owned = false;
36943         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36944         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
36945         return ret_conv;
36946 }
36947
36948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36949         LDKLightningError orig_conv;
36950         orig_conv.inner = (void*)(orig & (~1));
36951         orig_conv.is_owned = false;
36952         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36953         LDKLightningError ret_var = LightningError_clone(&orig_conv);
36954         int64_t ret_ref = 0;
36955         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36956         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36958         ret_ref = (uintptr_t)ret_var.inner;
36959         if (ret_var.is_owned) {
36960                 ret_ref |= 1;
36961         }
36962         return ret_ref;
36963 }
36964
36965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36966         LDKCommitmentUpdate 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         CommitmentUpdate_free(this_obj_conv);
36971 }
36972
36973 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
36974         LDKCommitmentUpdate 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         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
36979         int64_tArray ret_arr = NULL;
36980         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36981         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36982         for (size_t p = 0; p < ret_var.datalen; p++) {
36983                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
36984                 int64_t ret_conv_15_ref = 0;
36985                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36986                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36987                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
36988                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
36989                 if (ret_conv_15_var.is_owned) {
36990                         ret_conv_15_ref |= 1;
36991                 }
36992                 ret_arr_ptr[p] = ret_conv_15_ref;
36993         }
36994         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36995         FREE(ret_var.data);
36996         return ret_arr;
36997 }
36998
36999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37000         LDKCommitmentUpdate this_ptr_conv;
37001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37002         this_ptr_conv.is_owned = false;
37003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37004         LDKCVec_UpdateAddHTLCZ val_constr;
37005         val_constr.datalen = (*env)->GetArrayLength(env, val);
37006         if (val_constr.datalen > 0)
37007                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
37008         else
37009                 val_constr.data = NULL;
37010         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37011         for (size_t p = 0; p < val_constr.datalen; p++) {
37012                 int64_t val_conv_15 = val_vals[p];
37013                 LDKUpdateAddHTLC val_conv_15_conv;
37014                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
37015                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
37016                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
37017                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
37018                 val_constr.data[p] = val_conv_15_conv;
37019         }
37020         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37021         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
37022 }
37023
37024 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
37025         LDKCommitmentUpdate this_ptr_conv;
37026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37027         this_ptr_conv.is_owned = false;
37028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37029         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
37030         int64_tArray ret_arr = NULL;
37031         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37032         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37033         for (size_t t = 0; t < ret_var.datalen; t++) {
37034                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
37035                 int64_t ret_conv_19_ref = 0;
37036                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37037                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37038                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
37039                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
37040                 if (ret_conv_19_var.is_owned) {
37041                         ret_conv_19_ref |= 1;
37042                 }
37043                 ret_arr_ptr[t] = ret_conv_19_ref;
37044         }
37045         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37046         FREE(ret_var.data);
37047         return ret_arr;
37048 }
37049
37050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37051         LDKCommitmentUpdate this_ptr_conv;
37052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37053         this_ptr_conv.is_owned = false;
37054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37055         LDKCVec_UpdateFulfillHTLCZ val_constr;
37056         val_constr.datalen = (*env)->GetArrayLength(env, val);
37057         if (val_constr.datalen > 0)
37058                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
37059         else
37060                 val_constr.data = NULL;
37061         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37062         for (size_t t = 0; t < val_constr.datalen; t++) {
37063                 int64_t val_conv_19 = val_vals[t];
37064                 LDKUpdateFulfillHTLC val_conv_19_conv;
37065                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
37066                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
37067                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
37068                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
37069                 val_constr.data[t] = val_conv_19_conv;
37070         }
37071         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37072         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
37073 }
37074
37075 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
37076         LDKCommitmentUpdate this_ptr_conv;
37077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37078         this_ptr_conv.is_owned = false;
37079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37080         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
37081         int64_tArray ret_arr = NULL;
37082         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37083         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37084         for (size_t q = 0; q < ret_var.datalen; q++) {
37085                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
37086                 int64_t ret_conv_16_ref = 0;
37087                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37088                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37089                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
37090                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
37091                 if (ret_conv_16_var.is_owned) {
37092                         ret_conv_16_ref |= 1;
37093                 }
37094                 ret_arr_ptr[q] = ret_conv_16_ref;
37095         }
37096         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37097         FREE(ret_var.data);
37098         return ret_arr;
37099 }
37100
37101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37102         LDKCommitmentUpdate this_ptr_conv;
37103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37104         this_ptr_conv.is_owned = false;
37105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37106         LDKCVec_UpdateFailHTLCZ val_constr;
37107         val_constr.datalen = (*env)->GetArrayLength(env, val);
37108         if (val_constr.datalen > 0)
37109                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
37110         else
37111                 val_constr.data = NULL;
37112         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37113         for (size_t q = 0; q < val_constr.datalen; q++) {
37114                 int64_t val_conv_16 = val_vals[q];
37115                 LDKUpdateFailHTLC val_conv_16_conv;
37116                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
37117                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
37118                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
37119                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
37120                 val_constr.data[q] = val_conv_16_conv;
37121         }
37122         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37123         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
37124 }
37125
37126 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
37127         LDKCommitmentUpdate this_ptr_conv;
37128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37129         this_ptr_conv.is_owned = false;
37130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37131         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
37132         int64_tArray ret_arr = NULL;
37133         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37134         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37135         for (size_t z = 0; z < ret_var.datalen; z++) {
37136                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
37137                 int64_t ret_conv_25_ref = 0;
37138                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37139                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37140                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
37141                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
37142                 if (ret_conv_25_var.is_owned) {
37143                         ret_conv_25_ref |= 1;
37144                 }
37145                 ret_arr_ptr[z] = ret_conv_25_ref;
37146         }
37147         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37148         FREE(ret_var.data);
37149         return ret_arr;
37150 }
37151
37152 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) {
37153         LDKCommitmentUpdate this_ptr_conv;
37154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37155         this_ptr_conv.is_owned = false;
37156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37157         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
37158         val_constr.datalen = (*env)->GetArrayLength(env, val);
37159         if (val_constr.datalen > 0)
37160                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
37161         else
37162                 val_constr.data = NULL;
37163         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37164         for (size_t z = 0; z < val_constr.datalen; z++) {
37165                 int64_t val_conv_25 = val_vals[z];
37166                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
37167                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
37168                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
37169                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
37170                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
37171                 val_constr.data[z] = val_conv_25_conv;
37172         }
37173         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37174         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
37175 }
37176
37177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
37178         LDKCommitmentUpdate this_ptr_conv;
37179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37180         this_ptr_conv.is_owned = false;
37181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37182         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
37183         int64_t ret_ref = 0;
37184         if ((uintptr_t)ret_var.inner > 4096) {
37185                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37186                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37188                 ret_ref = (uintptr_t)ret_var.inner;
37189                 if (ret_var.is_owned) {
37190                         ret_ref |= 1;
37191                 }
37192         }
37193         return ret_ref;
37194 }
37195
37196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37197         LDKCommitmentUpdate this_ptr_conv;
37198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37199         this_ptr_conv.is_owned = false;
37200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37201         LDKUpdateFee val_conv;
37202         val_conv.inner = (void*)(val & (~1));
37203         val_conv.is_owned = (val & 1) || (val == 0);
37204         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37205         val_conv = UpdateFee_clone(&val_conv);
37206         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
37207 }
37208
37209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
37210         LDKCommitmentUpdate this_ptr_conv;
37211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37212         this_ptr_conv.is_owned = false;
37213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37214         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
37215         int64_t ret_ref = 0;
37216         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37217         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37219         ret_ref = (uintptr_t)ret_var.inner;
37220         if (ret_var.is_owned) {
37221                 ret_ref |= 1;
37222         }
37223         return ret_ref;
37224 }
37225
37226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37227         LDKCommitmentUpdate this_ptr_conv;
37228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37229         this_ptr_conv.is_owned = false;
37230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37231         LDKCommitmentSigned val_conv;
37232         val_conv.inner = (void*)(val & (~1));
37233         val_conv.is_owned = (val & 1) || (val == 0);
37234         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37235         val_conv = CommitmentSigned_clone(&val_conv);
37236         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
37237 }
37238
37239 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) {
37240         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
37241         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
37242         if (update_add_htlcs_arg_constr.datalen > 0)
37243                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
37244         else
37245                 update_add_htlcs_arg_constr.data = NULL;
37246         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
37247         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
37248                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
37249                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
37250                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
37251                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
37252                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
37253                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
37254                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
37255         }
37256         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
37257         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
37258         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
37259         if (update_fulfill_htlcs_arg_constr.datalen > 0)
37260                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
37261         else
37262                 update_fulfill_htlcs_arg_constr.data = NULL;
37263         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
37264         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
37265                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
37266                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
37267                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
37268                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
37269                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
37270                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
37271                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
37272         }
37273         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
37274         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
37275         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
37276         if (update_fail_htlcs_arg_constr.datalen > 0)
37277                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
37278         else
37279                 update_fail_htlcs_arg_constr.data = NULL;
37280         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
37281         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
37282                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
37283                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
37284                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
37285                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
37286                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
37287                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
37288                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
37289         }
37290         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
37291         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
37292         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
37293         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
37294                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
37295         else
37296                 update_fail_malformed_htlcs_arg_constr.data = NULL;
37297         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
37298         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
37299                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
37300                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
37301                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
37302                 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);
37303                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
37304                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
37305                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
37306         }
37307         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
37308         LDKUpdateFee update_fee_arg_conv;
37309         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
37310         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
37311         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
37312         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
37313         LDKCommitmentSigned commitment_signed_arg_conv;
37314         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
37315         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
37316         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
37317         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
37318         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);
37319         int64_t ret_ref = 0;
37320         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37321         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37323         ret_ref = (uintptr_t)ret_var.inner;
37324         if (ret_var.is_owned) {
37325                 ret_ref |= 1;
37326         }
37327         return ret_ref;
37328 }
37329
37330 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
37331         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
37332 int64_t ret_ref = 0;
37333 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37334 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37335 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37336 ret_ref = (uintptr_t)ret_var.inner;
37337 if (ret_var.is_owned) {
37338         ret_ref |= 1;
37339 }
37340         return ret_ref;
37341 }
37342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37343         LDKCommitmentUpdate arg_conv;
37344         arg_conv.inner = (void*)(arg & (~1));
37345         arg_conv.is_owned = false;
37346         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37347         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
37348         return ret_conv;
37349 }
37350
37351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37352         LDKCommitmentUpdate orig_conv;
37353         orig_conv.inner = (void*)(orig & (~1));
37354         orig_conv.is_owned = false;
37355         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37356         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
37357         int64_t ret_ref = 0;
37358         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37359         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37361         ret_ref = (uintptr_t)ret_var.inner;
37362         if (ret_var.is_owned) {
37363                 ret_ref |= 1;
37364         }
37365         return ret_ref;
37366 }
37367
37368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37369         if ((this_ptr & 1) != 0) return;
37370         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37371         CHECK_ACCESS(this_ptr_ptr);
37372         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
37373         FREE((void*)this_ptr);
37374         ChannelMessageHandler_free(this_ptr_conv);
37375 }
37376
37377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37378         if ((this_ptr & 1) != 0) return;
37379         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37380         CHECK_ACCESS(this_ptr_ptr);
37381         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
37382         FREE((void*)this_ptr);
37383         RoutingMessageHandler_free(this_ptr_conv);
37384 }
37385
37386 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
37387         LDKAcceptChannel obj_conv;
37388         obj_conv.inner = (void*)(obj & (~1));
37389         obj_conv.is_owned = false;
37390         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37391         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
37392         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37393         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37394         CVec_u8Z_free(ret_var);
37395         return ret_arr;
37396 }
37397
37398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37399         LDKu8slice ser_ref;
37400         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37401         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37402         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
37403         *ret_conv = AcceptChannel_read(ser_ref);
37404         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37405         return (int64_t)ret_conv;
37406 }
37407
37408 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
37409         LDKAnnouncementSignatures obj_conv;
37410         obj_conv.inner = (void*)(obj & (~1));
37411         obj_conv.is_owned = false;
37412         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37413         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
37414         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37415         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37416         CVec_u8Z_free(ret_var);
37417         return ret_arr;
37418 }
37419
37420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37421         LDKu8slice ser_ref;
37422         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37423         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37424         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
37425         *ret_conv = AnnouncementSignatures_read(ser_ref);
37426         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37427         return (int64_t)ret_conv;
37428 }
37429
37430 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
37431         LDKChannelReestablish obj_conv;
37432         obj_conv.inner = (void*)(obj & (~1));
37433         obj_conv.is_owned = false;
37434         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37435         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
37436         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37437         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37438         CVec_u8Z_free(ret_var);
37439         return ret_arr;
37440 }
37441
37442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37443         LDKu8slice ser_ref;
37444         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37445         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37446         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
37447         *ret_conv = ChannelReestablish_read(ser_ref);
37448         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37449         return (int64_t)ret_conv;
37450 }
37451
37452 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
37453         LDKClosingSigned obj_conv;
37454         obj_conv.inner = (void*)(obj & (~1));
37455         obj_conv.is_owned = false;
37456         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37457         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
37458         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37459         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37460         CVec_u8Z_free(ret_var);
37461         return ret_arr;
37462 }
37463
37464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37465         LDKu8slice ser_ref;
37466         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37467         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37468         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
37469         *ret_conv = ClosingSigned_read(ser_ref);
37470         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37471         return (int64_t)ret_conv;
37472 }
37473
37474 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
37475         LDKClosingSignedFeeRange obj_conv;
37476         obj_conv.inner = (void*)(obj & (~1));
37477         obj_conv.is_owned = false;
37478         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37479         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
37480         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37481         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37482         CVec_u8Z_free(ret_var);
37483         return ret_arr;
37484 }
37485
37486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37487         LDKu8slice ser_ref;
37488         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37489         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37490         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
37491         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
37492         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37493         return (int64_t)ret_conv;
37494 }
37495
37496 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
37497         LDKCommitmentSigned obj_conv;
37498         obj_conv.inner = (void*)(obj & (~1));
37499         obj_conv.is_owned = false;
37500         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37501         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
37502         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37503         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37504         CVec_u8Z_free(ret_var);
37505         return ret_arr;
37506 }
37507
37508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37509         LDKu8slice ser_ref;
37510         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37511         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37512         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
37513         *ret_conv = CommitmentSigned_read(ser_ref);
37514         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37515         return (int64_t)ret_conv;
37516 }
37517
37518 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
37519         LDKFundingCreated obj_conv;
37520         obj_conv.inner = (void*)(obj & (~1));
37521         obj_conv.is_owned = false;
37522         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37523         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
37524         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37525         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37526         CVec_u8Z_free(ret_var);
37527         return ret_arr;
37528 }
37529
37530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37531         LDKu8slice ser_ref;
37532         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37533         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37534         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
37535         *ret_conv = FundingCreated_read(ser_ref);
37536         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37537         return (int64_t)ret_conv;
37538 }
37539
37540 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
37541         LDKFundingSigned obj_conv;
37542         obj_conv.inner = (void*)(obj & (~1));
37543         obj_conv.is_owned = false;
37544         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37545         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
37546         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37547         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37548         CVec_u8Z_free(ret_var);
37549         return ret_arr;
37550 }
37551
37552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37553         LDKu8slice ser_ref;
37554         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37555         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37556         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
37557         *ret_conv = FundingSigned_read(ser_ref);
37558         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37559         return (int64_t)ret_conv;
37560 }
37561
37562 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1write(JNIEnv *env, jclass clz, int64_t obj) {
37563         LDKChannelReady obj_conv;
37564         obj_conv.inner = (void*)(obj & (~1));
37565         obj_conv.is_owned = false;
37566         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37567         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
37568         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37569         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37570         CVec_u8Z_free(ret_var);
37571         return ret_arr;
37572 }
37573
37574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37575         LDKu8slice ser_ref;
37576         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37577         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37578         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
37579         *ret_conv = ChannelReady_read(ser_ref);
37580         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37581         return (int64_t)ret_conv;
37582 }
37583
37584 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
37585         LDKInit obj_conv;
37586         obj_conv.inner = (void*)(obj & (~1));
37587         obj_conv.is_owned = false;
37588         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37589         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
37590         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37591         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37592         CVec_u8Z_free(ret_var);
37593         return ret_arr;
37594 }
37595
37596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37597         LDKu8slice ser_ref;
37598         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37599         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37600         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
37601         *ret_conv = Init_read(ser_ref);
37602         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37603         return (int64_t)ret_conv;
37604 }
37605
37606 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
37607         LDKOpenChannel obj_conv;
37608         obj_conv.inner = (void*)(obj & (~1));
37609         obj_conv.is_owned = false;
37610         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37611         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
37612         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37613         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37614         CVec_u8Z_free(ret_var);
37615         return ret_arr;
37616 }
37617
37618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37619         LDKu8slice ser_ref;
37620         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37621         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37622         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
37623         *ret_conv = OpenChannel_read(ser_ref);
37624         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37625         return (int64_t)ret_conv;
37626 }
37627
37628 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
37629         LDKRevokeAndACK obj_conv;
37630         obj_conv.inner = (void*)(obj & (~1));
37631         obj_conv.is_owned = false;
37632         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37633         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
37634         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37635         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37636         CVec_u8Z_free(ret_var);
37637         return ret_arr;
37638 }
37639
37640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37641         LDKu8slice ser_ref;
37642         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37643         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37644         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
37645         *ret_conv = RevokeAndACK_read(ser_ref);
37646         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37647         return (int64_t)ret_conv;
37648 }
37649
37650 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
37651         LDKShutdown obj_conv;
37652         obj_conv.inner = (void*)(obj & (~1));
37653         obj_conv.is_owned = false;
37654         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37655         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
37656         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37657         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37658         CVec_u8Z_free(ret_var);
37659         return ret_arr;
37660 }
37661
37662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37663         LDKu8slice ser_ref;
37664         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37665         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37666         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
37667         *ret_conv = Shutdown_read(ser_ref);
37668         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37669         return (int64_t)ret_conv;
37670 }
37671
37672 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37673         LDKUpdateFailHTLC obj_conv;
37674         obj_conv.inner = (void*)(obj & (~1));
37675         obj_conv.is_owned = false;
37676         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37677         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
37678         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37679         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37680         CVec_u8Z_free(ret_var);
37681         return ret_arr;
37682 }
37683
37684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37685         LDKu8slice ser_ref;
37686         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37687         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37688         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
37689         *ret_conv = UpdateFailHTLC_read(ser_ref);
37690         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37691         return (int64_t)ret_conv;
37692 }
37693
37694 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37695         LDKUpdateFailMalformedHTLC obj_conv;
37696         obj_conv.inner = (void*)(obj & (~1));
37697         obj_conv.is_owned = false;
37698         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37699         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
37700         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37701         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37702         CVec_u8Z_free(ret_var);
37703         return ret_arr;
37704 }
37705
37706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37707         LDKu8slice ser_ref;
37708         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37709         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37710         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
37711         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
37712         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37713         return (int64_t)ret_conv;
37714 }
37715
37716 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
37717         LDKUpdateFee obj_conv;
37718         obj_conv.inner = (void*)(obj & (~1));
37719         obj_conv.is_owned = false;
37720         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37721         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
37722         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37723         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37724         CVec_u8Z_free(ret_var);
37725         return ret_arr;
37726 }
37727
37728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37729         LDKu8slice ser_ref;
37730         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37731         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37732         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
37733         *ret_conv = UpdateFee_read(ser_ref);
37734         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37735         return (int64_t)ret_conv;
37736 }
37737
37738 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37739         LDKUpdateFulfillHTLC obj_conv;
37740         obj_conv.inner = (void*)(obj & (~1));
37741         obj_conv.is_owned = false;
37742         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37743         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
37744         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37745         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37746         CVec_u8Z_free(ret_var);
37747         return ret_arr;
37748 }
37749
37750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37751         LDKu8slice ser_ref;
37752         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37753         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37754         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
37755         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
37756         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37757         return (int64_t)ret_conv;
37758 }
37759
37760 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37761         LDKUpdateAddHTLC obj_conv;
37762         obj_conv.inner = (void*)(obj & (~1));
37763         obj_conv.is_owned = false;
37764         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37765         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
37766         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37767         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37768         CVec_u8Z_free(ret_var);
37769         return ret_arr;
37770 }
37771
37772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37773         LDKu8slice ser_ref;
37774         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37775         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37776         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
37777         *ret_conv = UpdateAddHTLC_read(ser_ref);
37778         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37779         return (int64_t)ret_conv;
37780 }
37781
37782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
37783         LDKPing obj_conv;
37784         obj_conv.inner = (void*)(obj & (~1));
37785         obj_conv.is_owned = false;
37786         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37787         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
37788         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37789         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37790         CVec_u8Z_free(ret_var);
37791         return ret_arr;
37792 }
37793
37794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37795         LDKu8slice ser_ref;
37796         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37797         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37798         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
37799         *ret_conv = Ping_read(ser_ref);
37800         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37801         return (int64_t)ret_conv;
37802 }
37803
37804 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
37805         LDKPong obj_conv;
37806         obj_conv.inner = (void*)(obj & (~1));
37807         obj_conv.is_owned = false;
37808         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37809         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
37810         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37811         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37812         CVec_u8Z_free(ret_var);
37813         return ret_arr;
37814 }
37815
37816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37817         LDKu8slice ser_ref;
37818         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37819         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37820         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
37821         *ret_conv = Pong_read(ser_ref);
37822         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37823         return (int64_t)ret_conv;
37824 }
37825
37826 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37827         LDKUnsignedChannelAnnouncement obj_conv;
37828         obj_conv.inner = (void*)(obj & (~1));
37829         obj_conv.is_owned = false;
37830         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37831         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
37832         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37833         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37834         CVec_u8Z_free(ret_var);
37835         return ret_arr;
37836 }
37837
37838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37839         LDKu8slice ser_ref;
37840         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37841         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37842         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
37843         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
37844         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37845         return (int64_t)ret_conv;
37846 }
37847
37848 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37849         LDKChannelAnnouncement obj_conv;
37850         obj_conv.inner = (void*)(obj & (~1));
37851         obj_conv.is_owned = false;
37852         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37853         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
37854         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37855         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37856         CVec_u8Z_free(ret_var);
37857         return ret_arr;
37858 }
37859
37860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37861         LDKu8slice ser_ref;
37862         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37863         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37864         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
37865         *ret_conv = ChannelAnnouncement_read(ser_ref);
37866         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37867         return (int64_t)ret_conv;
37868 }
37869
37870 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
37871         LDKUnsignedChannelUpdate obj_conv;
37872         obj_conv.inner = (void*)(obj & (~1));
37873         obj_conv.is_owned = false;
37874         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37875         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
37876         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37877         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37878         CVec_u8Z_free(ret_var);
37879         return ret_arr;
37880 }
37881
37882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37883         LDKu8slice ser_ref;
37884         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37885         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37886         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
37887         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
37888         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37889         return (int64_t)ret_conv;
37890 }
37891
37892 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
37893         LDKChannelUpdate obj_conv;
37894         obj_conv.inner = (void*)(obj & (~1));
37895         obj_conv.is_owned = false;
37896         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37897         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
37898         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37899         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37900         CVec_u8Z_free(ret_var);
37901         return ret_arr;
37902 }
37903
37904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37905         LDKu8slice ser_ref;
37906         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37907         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37908         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
37909         *ret_conv = ChannelUpdate_read(ser_ref);
37910         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37911         return (int64_t)ret_conv;
37912 }
37913
37914 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
37915         LDKErrorMessage obj_conv;
37916         obj_conv.inner = (void*)(obj & (~1));
37917         obj_conv.is_owned = false;
37918         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37919         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
37920         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37921         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37922         CVec_u8Z_free(ret_var);
37923         return ret_arr;
37924 }
37925
37926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37927         LDKu8slice ser_ref;
37928         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37929         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37930         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
37931         *ret_conv = ErrorMessage_read(ser_ref);
37932         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37933         return (int64_t)ret_conv;
37934 }
37935
37936 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
37937         LDKWarningMessage obj_conv;
37938         obj_conv.inner = (void*)(obj & (~1));
37939         obj_conv.is_owned = false;
37940         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37941         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
37942         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37943         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37944         CVec_u8Z_free(ret_var);
37945         return ret_arr;
37946 }
37947
37948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37949         LDKu8slice ser_ref;
37950         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37951         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37952         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
37953         *ret_conv = WarningMessage_read(ser_ref);
37954         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37955         return (int64_t)ret_conv;
37956 }
37957
37958 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37959         LDKUnsignedNodeAnnouncement obj_conv;
37960         obj_conv.inner = (void*)(obj & (~1));
37961         obj_conv.is_owned = false;
37962         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37963         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
37964         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37965         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37966         CVec_u8Z_free(ret_var);
37967         return ret_arr;
37968 }
37969
37970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37971         LDKu8slice ser_ref;
37972         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37973         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37974         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
37975         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
37976         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37977         return (int64_t)ret_conv;
37978 }
37979
37980 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37981         LDKNodeAnnouncement obj_conv;
37982         obj_conv.inner = (void*)(obj & (~1));
37983         obj_conv.is_owned = false;
37984         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37985         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
37986         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37987         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37988         CVec_u8Z_free(ret_var);
37989         return ret_arr;
37990 }
37991
37992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37993         LDKu8slice ser_ref;
37994         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37995         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37996         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
37997         *ret_conv = NodeAnnouncement_read(ser_ref);
37998         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37999         return (int64_t)ret_conv;
38000 }
38001
38002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38003         LDKu8slice ser_ref;
38004         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38005         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38006         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
38007         *ret_conv = QueryShortChannelIds_read(ser_ref);
38008         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38009         return (int64_t)ret_conv;
38010 }
38011
38012 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
38013         LDKQueryShortChannelIds obj_conv;
38014         obj_conv.inner = (void*)(obj & (~1));
38015         obj_conv.is_owned = false;
38016         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38017         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
38018         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38019         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38020         CVec_u8Z_free(ret_var);
38021         return ret_arr;
38022 }
38023
38024 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
38025         LDKReplyShortChannelIdsEnd obj_conv;
38026         obj_conv.inner = (void*)(obj & (~1));
38027         obj_conv.is_owned = false;
38028         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38029         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
38030         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38031         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38032         CVec_u8Z_free(ret_var);
38033         return ret_arr;
38034 }
38035
38036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38037         LDKu8slice ser_ref;
38038         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38039         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38040         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
38041         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
38042         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38043         return (int64_t)ret_conv;
38044 }
38045
38046 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
38047         LDKQueryChannelRange this_arg_conv;
38048         this_arg_conv.inner = (void*)(this_arg & (~1));
38049         this_arg_conv.is_owned = false;
38050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38051         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
38052         return ret_conv;
38053 }
38054
38055 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
38056         LDKQueryChannelRange obj_conv;
38057         obj_conv.inner = (void*)(obj & (~1));
38058         obj_conv.is_owned = false;
38059         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38060         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
38061         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38062         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38063         CVec_u8Z_free(ret_var);
38064         return ret_arr;
38065 }
38066
38067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38068         LDKu8slice ser_ref;
38069         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38070         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38071         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
38072         *ret_conv = QueryChannelRange_read(ser_ref);
38073         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38074         return (int64_t)ret_conv;
38075 }
38076
38077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_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_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
38082         *ret_conv = ReplyChannelRange_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_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
38088         LDKReplyChannelRange 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 = ReplyChannelRange_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 int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
38100         LDKGossipTimestampFilter obj_conv;
38101         obj_conv.inner = (void*)(obj & (~1));
38102         obj_conv.is_owned = false;
38103         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38104         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
38105         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38106         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38107         CVec_u8Z_free(ret_var);
38108         return ret_arr;
38109 }
38110
38111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38112         LDKu8slice ser_ref;
38113         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38114         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38115         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
38116         *ret_conv = GossipTimestampFilter_read(ser_ref);
38117         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38118         return (int64_t)ret_conv;
38119 }
38120
38121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38122         if ((this_ptr & 1) != 0) return;
38123         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38124         CHECK_ACCESS(this_ptr_ptr);
38125         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
38126         FREE((void*)this_ptr);
38127         CustomMessageHandler_free(this_ptr_conv);
38128 }
38129
38130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38131         LDKIgnoringMessageHandler this_obj_conv;
38132         this_obj_conv.inner = (void*)(this_obj & (~1));
38133         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38135         IgnoringMessageHandler_free(this_obj_conv);
38136 }
38137
38138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
38139         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
38140         int64_t ret_ref = 0;
38141         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38142         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38144         ret_ref = (uintptr_t)ret_var.inner;
38145         if (ret_var.is_owned) {
38146                 ret_ref |= 1;
38147         }
38148         return ret_ref;
38149 }
38150
38151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
38152         LDKIgnoringMessageHandler this_arg_conv;
38153         this_arg_conv.inner = (void*)(this_arg & (~1));
38154         this_arg_conv.is_owned = false;
38155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38156         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
38157         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
38158         return (int64_t)ret_ret;
38159 }
38160
38161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
38162         LDKIgnoringMessageHandler this_arg_conv;
38163         this_arg_conv.inner = (void*)(this_arg & (~1));
38164         this_arg_conv.is_owned = false;
38165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38166         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
38167         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
38168         return (int64_t)ret_ret;
38169 }
38170
38171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
38172         LDKIgnoringMessageHandler this_arg_conv;
38173         this_arg_conv.inner = (void*)(this_arg & (~1));
38174         this_arg_conv.is_owned = false;
38175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38176         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
38177         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
38178         return (int64_t)ret_ret;
38179 }
38180
38181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
38182         LDKIgnoringMessageHandler this_arg_conv;
38183         this_arg_conv.inner = (void*)(this_arg & (~1));
38184         this_arg_conv.is_owned = false;
38185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38186         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
38187         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
38188         return (int64_t)ret_ret;
38189 }
38190
38191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38192         LDKErroringMessageHandler this_obj_conv;
38193         this_obj_conv.inner = (void*)(this_obj & (~1));
38194         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38196         ErroringMessageHandler_free(this_obj_conv);
38197 }
38198
38199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
38200         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
38201         int64_t ret_ref = 0;
38202         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38203         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38204         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38205         ret_ref = (uintptr_t)ret_var.inner;
38206         if (ret_var.is_owned) {
38207                 ret_ref |= 1;
38208         }
38209         return ret_ref;
38210 }
38211
38212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
38213         LDKErroringMessageHandler this_arg_conv;
38214         this_arg_conv.inner = (void*)(this_arg & (~1));
38215         this_arg_conv.is_owned = false;
38216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38217         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
38218         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
38219         return (int64_t)ret_ret;
38220 }
38221
38222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
38223         LDKErroringMessageHandler this_arg_conv;
38224         this_arg_conv.inner = (void*)(this_arg & (~1));
38225         this_arg_conv.is_owned = false;
38226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38227         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
38228         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
38229         return (int64_t)ret_ret;
38230 }
38231
38232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38233         LDKMessageHandler this_obj_conv;
38234         this_obj_conv.inner = (void*)(this_obj & (~1));
38235         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38237         MessageHandler_free(this_obj_conv);
38238 }
38239
38240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
38241         LDKMessageHandler this_ptr_conv;
38242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38243         this_ptr_conv.is_owned = false;
38244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38245         // WARNING: This object doesn't live past this scope, needs clone!
38246         int64_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
38247         return ret_ret;
38248 }
38249
38250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38251         LDKMessageHandler this_ptr_conv;
38252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38253         this_ptr_conv.is_owned = false;
38254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38255         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38256         CHECK_ACCESS(val_ptr);
38257         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
38258         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
38259                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38260                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
38261         }
38262         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
38263 }
38264
38265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
38266         LDKMessageHandler this_ptr_conv;
38267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38268         this_ptr_conv.is_owned = false;
38269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38270         // WARNING: This object doesn't live past this scope, needs clone!
38271         int64_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
38272         return ret_ret;
38273 }
38274
38275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38276         LDKMessageHandler this_ptr_conv;
38277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38278         this_ptr_conv.is_owned = false;
38279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38280         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38281         CHECK_ACCESS(val_ptr);
38282         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
38283         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
38284                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38285                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
38286         }
38287         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
38288 }
38289
38290 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) {
38291         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
38292         CHECK_ACCESS(chan_handler_arg_ptr);
38293         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
38294         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
38295                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38296                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
38297         }
38298         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
38299         CHECK_ACCESS(route_handler_arg_ptr);
38300         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
38301         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
38302                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38303                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
38304         }
38305         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
38306         int64_t ret_ref = 0;
38307         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38308         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38309         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38310         ret_ref = (uintptr_t)ret_var.inner;
38311         if (ret_var.is_owned) {
38312                 ret_ref |= 1;
38313         }
38314         return ret_ref;
38315 }
38316
38317 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
38318         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
38319         *ret_ret = SocketDescriptor_clone(arg);
38320         return (int64_t)ret_ret;
38321 }
38322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38323         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
38324         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
38325         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
38326         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
38327         return ret_conv;
38328 }
38329
38330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38331         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
38332         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
38333         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
38334         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
38335         *ret_ret = SocketDescriptor_clone(orig_conv);
38336         return (int64_t)ret_ret;
38337 }
38338
38339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38340         if ((this_ptr & 1) != 0) return;
38341         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38342         CHECK_ACCESS(this_ptr_ptr);
38343         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
38344         FREE((void*)this_ptr);
38345         SocketDescriptor_free(this_ptr_conv);
38346 }
38347
38348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38349         LDKPeerHandleError this_obj_conv;
38350         this_obj_conv.inner = (void*)(this_obj & (~1));
38351         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38353         PeerHandleError_free(this_obj_conv);
38354 }
38355
38356 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
38357         LDKPeerHandleError this_ptr_conv;
38358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38359         this_ptr_conv.is_owned = false;
38360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38361         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
38362         return ret_conv;
38363 }
38364
38365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
38366         LDKPeerHandleError this_ptr_conv;
38367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38368         this_ptr_conv.is_owned = false;
38369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38370         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
38371 }
38372
38373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
38374         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
38375         int64_t ret_ref = 0;
38376         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38377         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38379         ret_ref = (uintptr_t)ret_var.inner;
38380         if (ret_var.is_owned) {
38381                 ret_ref |= 1;
38382         }
38383         return ret_ref;
38384 }
38385
38386 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
38387         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
38388 int64_t ret_ref = 0;
38389 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38390 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38391 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38392 ret_ref = (uintptr_t)ret_var.inner;
38393 if (ret_var.is_owned) {
38394         ret_ref |= 1;
38395 }
38396         return ret_ref;
38397 }
38398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38399         LDKPeerHandleError arg_conv;
38400         arg_conv.inner = (void*)(arg & (~1));
38401         arg_conv.is_owned = false;
38402         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38403         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
38404         return ret_conv;
38405 }
38406
38407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38408         LDKPeerHandleError orig_conv;
38409         orig_conv.inner = (void*)(orig & (~1));
38410         orig_conv.is_owned = false;
38411         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38412         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_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 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38425         LDKPeerManager this_obj_conv;
38426         this_obj_conv.inner = (void*)(this_obj & (~1));
38427         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38429         PeerManager_free(this_obj_conv);
38430 }
38431
38432 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) {
38433         LDKMessageHandler message_handler_conv;
38434         message_handler_conv.inner = (void*)(message_handler & (~1));
38435         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
38436         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
38437         // WARNING: we need a move here but no clone is available for LDKMessageHandler
38438         LDKSecretKey our_node_secret_ref;
38439         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
38440         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
38441         unsigned char ephemeral_random_data_arr[32];
38442         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
38443         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
38444         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
38445         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
38446         CHECK_ACCESS(logger_ptr);
38447         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
38448         if (logger_conv.free == LDKLogger_JCalls_free) {
38449                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38450                 LDKLogger_JCalls_cloned(&logger_conv);
38451         }
38452         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
38453         CHECK_ACCESS(custom_message_handler_ptr);
38454         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
38455         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
38456                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38457                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
38458         }
38459         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
38460         int64_t ret_ref = 0;
38461         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38462         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38464         ret_ref = (uintptr_t)ret_var.inner;
38465         if (ret_var.is_owned) {
38466                 ret_ref |= 1;
38467         }
38468         return ret_ref;
38469 }
38470
38471 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
38472         LDKPeerManager this_arg_conv;
38473         this_arg_conv.inner = (void*)(this_arg & (~1));
38474         this_arg_conv.is_owned = false;
38475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38476         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
38477         jobjectArray ret_arr = NULL;
38478         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
38479         ;
38480         for (size_t i = 0; i < ret_var.datalen; i++) {
38481                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
38482                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
38483                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
38484         }
38485         
38486         FREE(ret_var.data);
38487         return ret_arr;
38488 }
38489
38490 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) {
38491         LDKPeerManager this_arg_conv;
38492         this_arg_conv.inner = (void*)(this_arg & (~1));
38493         this_arg_conv.is_owned = false;
38494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38495         LDKPublicKey their_node_id_ref;
38496         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
38497         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
38498         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
38499         CHECK_ACCESS(descriptor_ptr);
38500         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
38501         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
38502                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38503                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
38504         }
38505         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
38506         CHECK_ACCESS(remote_network_address_ptr);
38507         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
38508         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
38509         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
38510         return (int64_t)ret_conv;
38511 }
38512
38513 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) {
38514         LDKPeerManager this_arg_conv;
38515         this_arg_conv.inner = (void*)(this_arg & (~1));
38516         this_arg_conv.is_owned = false;
38517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38518         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
38519         CHECK_ACCESS(descriptor_ptr);
38520         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
38521         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
38522                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38523                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
38524         }
38525         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
38526         CHECK_ACCESS(remote_network_address_ptr);
38527         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
38528         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
38529         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
38530         return (int64_t)ret_conv;
38531 }
38532
38533 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) {
38534         LDKPeerManager this_arg_conv;
38535         this_arg_conv.inner = (void*)(this_arg & (~1));
38536         this_arg_conv.is_owned = false;
38537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38538         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
38539         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
38540         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
38541         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
38542         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
38543         return (int64_t)ret_conv;
38544 }
38545
38546 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) {
38547         LDKPeerManager this_arg_conv;
38548         this_arg_conv.inner = (void*)(this_arg & (~1));
38549         this_arg_conv.is_owned = false;
38550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38551         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
38552         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
38553         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
38554         LDKu8slice data_ref;
38555         data_ref.datalen = (*env)->GetArrayLength(env, data);
38556         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
38557         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
38558         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
38559         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
38560         return (int64_t)ret_conv;
38561 }
38562
38563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
38564         LDKPeerManager this_arg_conv;
38565         this_arg_conv.inner = (void*)(this_arg & (~1));
38566         this_arg_conv.is_owned = false;
38567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38568         PeerManager_process_events(&this_arg_conv);
38569 }
38570
38571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
38572         LDKPeerManager this_arg_conv;
38573         this_arg_conv.inner = (void*)(this_arg & (~1));
38574         this_arg_conv.is_owned = false;
38575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38576         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
38577         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
38578         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
38579         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
38580 }
38581
38582 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) {
38583         LDKPeerManager this_arg_conv;
38584         this_arg_conv.inner = (void*)(this_arg & (~1));
38585         this_arg_conv.is_owned = false;
38586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38587         LDKPublicKey node_id_ref;
38588         CHECK((*env)->GetArrayLength(env, node_id) == 33);
38589         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
38590         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
38591 }
38592
38593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
38594         LDKPeerManager this_arg_conv;
38595         this_arg_conv.inner = (void*)(this_arg & (~1));
38596         this_arg_conv.is_owned = false;
38597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38598         PeerManager_disconnect_all_peers(&this_arg_conv);
38599 }
38600
38601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
38602         LDKPeerManager this_arg_conv;
38603         this_arg_conv.inner = (void*)(this_arg & (~1));
38604         this_arg_conv.is_owned = false;
38605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38606         PeerManager_timer_tick_occurred(&this_arg_conv);
38607 }
38608
38609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
38610         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
38611         return ret_conv;
38612 }
38613
38614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
38615         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
38616         return ret_conv;
38617 }
38618
38619 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
38620         unsigned char commitment_seed_arr[32];
38621         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
38622         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
38623         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
38624         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38625         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
38626         return ret_arr;
38627 }
38628
38629 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) {
38630         LDKCVec_u8Z to_holder_script_ref;
38631         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
38632         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
38633         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
38634         LDKCVec_u8Z to_counterparty_script_ref;
38635         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
38636         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
38637         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
38638         LDKOutPoint funding_outpoint_conv;
38639         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
38640         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
38641         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
38642         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
38643         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);
38644         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38645         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38646         Transaction_free(ret_var);
38647         return ret_arr;
38648 }
38649
38650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38651         LDKCounterpartyCommitmentSecrets this_obj_conv;
38652         this_obj_conv.inner = (void*)(this_obj & (~1));
38653         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38655         CounterpartyCommitmentSecrets_free(this_obj_conv);
38656 }
38657
38658 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
38659         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
38660 int64_t ret_ref = 0;
38661 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38662 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38663 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38664 ret_ref = (uintptr_t)ret_var.inner;
38665 if (ret_var.is_owned) {
38666         ret_ref |= 1;
38667 }
38668         return ret_ref;
38669 }
38670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38671         LDKCounterpartyCommitmentSecrets arg_conv;
38672         arg_conv.inner = (void*)(arg & (~1));
38673         arg_conv.is_owned = false;
38674         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38675         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
38676         return ret_conv;
38677 }
38678
38679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38680         LDKCounterpartyCommitmentSecrets orig_conv;
38681         orig_conv.inner = (void*)(orig & (~1));
38682         orig_conv.is_owned = false;
38683         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38684         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
38685         int64_t ret_ref = 0;
38686         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38687         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38689         ret_ref = (uintptr_t)ret_var.inner;
38690         if (ret_var.is_owned) {
38691                 ret_ref |= 1;
38692         }
38693         return ret_ref;
38694 }
38695
38696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
38697         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
38698         int64_t ret_ref = 0;
38699         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38700         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38702         ret_ref = (uintptr_t)ret_var.inner;
38703         if (ret_var.is_owned) {
38704                 ret_ref |= 1;
38705         }
38706         return ret_ref;
38707 }
38708
38709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
38710         LDKCounterpartyCommitmentSecrets this_arg_conv;
38711         this_arg_conv.inner = (void*)(this_arg & (~1));
38712         this_arg_conv.is_owned = false;
38713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38714         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
38715         return ret_conv;
38716 }
38717
38718 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) {
38719         LDKCounterpartyCommitmentSecrets this_arg_conv;
38720         this_arg_conv.inner = (void*)(this_arg & (~1));
38721         this_arg_conv.is_owned = false;
38722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38723         LDKThirtyTwoBytes secret_ref;
38724         CHECK((*env)->GetArrayLength(env, secret) == 32);
38725         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
38726         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
38727         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
38728         return (int64_t)ret_conv;
38729 }
38730
38731 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
38732         LDKCounterpartyCommitmentSecrets this_arg_conv;
38733         this_arg_conv.inner = (void*)(this_arg & (~1));
38734         this_arg_conv.is_owned = false;
38735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38736         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38737         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
38738         return ret_arr;
38739 }
38740
38741 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
38742         LDKCounterpartyCommitmentSecrets obj_conv;
38743         obj_conv.inner = (void*)(obj & (~1));
38744         obj_conv.is_owned = false;
38745         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38746         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
38747         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38748         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38749         CVec_u8Z_free(ret_var);
38750         return ret_arr;
38751 }
38752
38753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38754         LDKu8slice ser_ref;
38755         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38756         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38757         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
38758         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
38759         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38760         return (int64_t)ret_conv;
38761 }
38762
38763 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) {
38764         LDKPublicKey per_commitment_point_ref;
38765         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38766         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38767         unsigned char base_secret_arr[32];
38768         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
38769         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
38770         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
38771         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
38772         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
38773         return (int64_t)ret_conv;
38774 }
38775
38776 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) {
38777         LDKPublicKey per_commitment_point_ref;
38778         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38779         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38780         LDKPublicKey base_point_ref;
38781         CHECK((*env)->GetArrayLength(env, base_point) == 33);
38782         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
38783         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
38784         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
38785         return (int64_t)ret_conv;
38786 }
38787
38788 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) {
38789         unsigned char per_commitment_secret_arr[32];
38790         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
38791         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
38792         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
38793         unsigned char countersignatory_revocation_base_secret_arr[32];
38794         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
38795         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
38796         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
38797         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
38798         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
38799         return (int64_t)ret_conv;
38800 }
38801
38802 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) {
38803         LDKPublicKey per_commitment_point_ref;
38804         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38805         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38806         LDKPublicKey countersignatory_revocation_base_point_ref;
38807         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
38808         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
38809         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
38810         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
38811         return (int64_t)ret_conv;
38812 }
38813
38814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38815         LDKTxCreationKeys this_obj_conv;
38816         this_obj_conv.inner = (void*)(this_obj & (~1));
38817         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38819         TxCreationKeys_free(this_obj_conv);
38820 }
38821
38822 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
38823         LDKTxCreationKeys this_ptr_conv;
38824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38825         this_ptr_conv.is_owned = false;
38826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38827         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38828         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
38829         return ret_arr;
38830 }
38831
38832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38833         LDKTxCreationKeys this_ptr_conv;
38834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38835         this_ptr_conv.is_owned = false;
38836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38837         LDKPublicKey val_ref;
38838         CHECK((*env)->GetArrayLength(env, val) == 33);
38839         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38840         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
38841 }
38842
38843 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38844         LDKTxCreationKeys this_ptr_conv;
38845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38846         this_ptr_conv.is_owned = false;
38847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38848         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38849         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
38850         return ret_arr;
38851 }
38852
38853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38854         LDKTxCreationKeys this_ptr_conv;
38855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38856         this_ptr_conv.is_owned = false;
38857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38858         LDKPublicKey val_ref;
38859         CHECK((*env)->GetArrayLength(env, val) == 33);
38860         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38861         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
38862 }
38863
38864 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38865         LDKTxCreationKeys this_ptr_conv;
38866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38867         this_ptr_conv.is_owned = false;
38868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38869         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38870         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
38871         return ret_arr;
38872 }
38873
38874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38875         LDKTxCreationKeys this_ptr_conv;
38876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38877         this_ptr_conv.is_owned = false;
38878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38879         LDKPublicKey val_ref;
38880         CHECK((*env)->GetArrayLength(env, val) == 33);
38881         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38882         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
38883 }
38884
38885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38886         LDKTxCreationKeys this_ptr_conv;
38887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38888         this_ptr_conv.is_owned = false;
38889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38890         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38891         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
38892         return ret_arr;
38893 }
38894
38895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38896         LDKTxCreationKeys this_ptr_conv;
38897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38898         this_ptr_conv.is_owned = false;
38899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38900         LDKPublicKey val_ref;
38901         CHECK((*env)->GetArrayLength(env, val) == 33);
38902         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38903         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
38904 }
38905
38906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38907         LDKTxCreationKeys this_ptr_conv;
38908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38909         this_ptr_conv.is_owned = false;
38910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38911         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38912         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
38913         return ret_arr;
38914 }
38915
38916 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) {
38917         LDKTxCreationKeys this_ptr_conv;
38918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38919         this_ptr_conv.is_owned = false;
38920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38921         LDKPublicKey val_ref;
38922         CHECK((*env)->GetArrayLength(env, val) == 33);
38923         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38924         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
38925 }
38926
38927 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) {
38928         LDKPublicKey per_commitment_point_arg_ref;
38929         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
38930         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
38931         LDKPublicKey revocation_key_arg_ref;
38932         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
38933         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
38934         LDKPublicKey broadcaster_htlc_key_arg_ref;
38935         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
38936         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
38937         LDKPublicKey countersignatory_htlc_key_arg_ref;
38938         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
38939         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
38940         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
38941         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
38942         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
38943         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);
38944         int64_t ret_ref = 0;
38945         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38946         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38948         ret_ref = (uintptr_t)ret_var.inner;
38949         if (ret_var.is_owned) {
38950                 ret_ref |= 1;
38951         }
38952         return ret_ref;
38953 }
38954
38955 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
38956         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
38957 int64_t ret_ref = 0;
38958 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38959 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38960 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38961 ret_ref = (uintptr_t)ret_var.inner;
38962 if (ret_var.is_owned) {
38963         ret_ref |= 1;
38964 }
38965         return ret_ref;
38966 }
38967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38968         LDKTxCreationKeys arg_conv;
38969         arg_conv.inner = (void*)(arg & (~1));
38970         arg_conv.is_owned = false;
38971         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38972         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
38973         return ret_conv;
38974 }
38975
38976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38977         LDKTxCreationKeys orig_conv;
38978         orig_conv.inner = (void*)(orig & (~1));
38979         orig_conv.is_owned = false;
38980         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38981         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
38982         int64_t ret_ref = 0;
38983         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38984         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38986         ret_ref = (uintptr_t)ret_var.inner;
38987         if (ret_var.is_owned) {
38988                 ret_ref |= 1;
38989         }
38990         return ret_ref;
38991 }
38992
38993 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
38994         LDKTxCreationKeys obj_conv;
38995         obj_conv.inner = (void*)(obj & (~1));
38996         obj_conv.is_owned = false;
38997         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38998         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
38999         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39000         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39001         CVec_u8Z_free(ret_var);
39002         return ret_arr;
39003 }
39004
39005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39006         LDKu8slice ser_ref;
39007         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39008         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39009         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
39010         *ret_conv = TxCreationKeys_read(ser_ref);
39011         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39012         return (int64_t)ret_conv;
39013 }
39014
39015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39016         LDKChannelPublicKeys this_obj_conv;
39017         this_obj_conv.inner = (void*)(this_obj & (~1));
39018         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39020         ChannelPublicKeys_free(this_obj_conv);
39021 }
39022
39023 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
39024         LDKChannelPublicKeys 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39029         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
39030         return ret_arr;
39031 }
39032
39033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39034         LDKChannelPublicKeys this_ptr_conv;
39035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39036         this_ptr_conv.is_owned = false;
39037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39038         LDKPublicKey val_ref;
39039         CHECK((*env)->GetArrayLength(env, val) == 33);
39040         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39041         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
39042 }
39043
39044 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39045         LDKChannelPublicKeys this_ptr_conv;
39046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39047         this_ptr_conv.is_owned = false;
39048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39049         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39050         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
39051         return ret_arr;
39052 }
39053
39054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39055         LDKChannelPublicKeys this_ptr_conv;
39056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39057         this_ptr_conv.is_owned = false;
39058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39059         LDKPublicKey val_ref;
39060         CHECK((*env)->GetArrayLength(env, val) == 33);
39061         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39062         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
39063 }
39064
39065 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
39066         LDKChannelPublicKeys this_ptr_conv;
39067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39068         this_ptr_conv.is_owned = false;
39069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39070         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39071         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
39072         return ret_arr;
39073 }
39074
39075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39076         LDKChannelPublicKeys this_ptr_conv;
39077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39078         this_ptr_conv.is_owned = false;
39079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39080         LDKPublicKey val_ref;
39081         CHECK((*env)->GetArrayLength(env, val) == 33);
39082         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39083         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
39084 }
39085
39086 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39087         LDKChannelPublicKeys this_ptr_conv;
39088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39089         this_ptr_conv.is_owned = false;
39090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39091         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39092         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
39093         return ret_arr;
39094 }
39095
39096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39097         LDKChannelPublicKeys this_ptr_conv;
39098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39099         this_ptr_conv.is_owned = false;
39100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39101         LDKPublicKey val_ref;
39102         CHECK((*env)->GetArrayLength(env, val) == 33);
39103         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39104         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
39105 }
39106
39107 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39108         LDKChannelPublicKeys this_ptr_conv;
39109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39110         this_ptr_conv.is_owned = false;
39111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39112         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39113         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
39114         return ret_arr;
39115 }
39116
39117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39118         LDKChannelPublicKeys this_ptr_conv;
39119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39120         this_ptr_conv.is_owned = false;
39121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39122         LDKPublicKey val_ref;
39123         CHECK((*env)->GetArrayLength(env, val) == 33);
39124         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39125         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
39126 }
39127
39128 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) {
39129         LDKPublicKey funding_pubkey_arg_ref;
39130         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
39131         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
39132         LDKPublicKey revocation_basepoint_arg_ref;
39133         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
39134         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
39135         LDKPublicKey payment_point_arg_ref;
39136         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
39137         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
39138         LDKPublicKey delayed_payment_basepoint_arg_ref;
39139         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
39140         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
39141         LDKPublicKey htlc_basepoint_arg_ref;
39142         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
39143         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
39144         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);
39145         int64_t ret_ref = 0;
39146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39149         ret_ref = (uintptr_t)ret_var.inner;
39150         if (ret_var.is_owned) {
39151                 ret_ref |= 1;
39152         }
39153         return ret_ref;
39154 }
39155
39156 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
39157         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
39158 int64_t ret_ref = 0;
39159 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39160 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39161 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39162 ret_ref = (uintptr_t)ret_var.inner;
39163 if (ret_var.is_owned) {
39164         ret_ref |= 1;
39165 }
39166         return ret_ref;
39167 }
39168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39169         LDKChannelPublicKeys arg_conv;
39170         arg_conv.inner = (void*)(arg & (~1));
39171         arg_conv.is_owned = false;
39172         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39173         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
39174         return ret_conv;
39175 }
39176
39177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39178         LDKChannelPublicKeys orig_conv;
39179         orig_conv.inner = (void*)(orig & (~1));
39180         orig_conv.is_owned = false;
39181         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39182         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
39183         int64_t ret_ref = 0;
39184         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39185         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39186         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39187         ret_ref = (uintptr_t)ret_var.inner;
39188         if (ret_var.is_owned) {
39189                 ret_ref |= 1;
39190         }
39191         return ret_ref;
39192 }
39193
39194 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
39195         LDKChannelPublicKeys obj_conv;
39196         obj_conv.inner = (void*)(obj & (~1));
39197         obj_conv.is_owned = false;
39198         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39199         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
39200         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39201         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39202         CVec_u8Z_free(ret_var);
39203         return ret_arr;
39204 }
39205
39206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39207         LDKu8slice ser_ref;
39208         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39209         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39210         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
39211         *ret_conv = ChannelPublicKeys_read(ser_ref);
39212         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39213         return (int64_t)ret_conv;
39214 }
39215
39216 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) {
39217         LDKPublicKey per_commitment_point_ref;
39218         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
39219         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
39220         LDKPublicKey broadcaster_delayed_payment_base_ref;
39221         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
39222         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
39223         LDKPublicKey broadcaster_htlc_base_ref;
39224         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
39225         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
39226         LDKPublicKey countersignatory_revocation_base_ref;
39227         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
39228         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
39229         LDKPublicKey countersignatory_htlc_base_ref;
39230         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
39231         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
39232         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
39233         *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);
39234         return (int64_t)ret_conv;
39235 }
39236
39237 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) {
39238         LDKPublicKey per_commitment_point_ref;
39239         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
39240         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
39241         LDKChannelPublicKeys broadcaster_keys_conv;
39242         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
39243         broadcaster_keys_conv.is_owned = false;
39244         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
39245         LDKChannelPublicKeys countersignatory_keys_conv;
39246         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
39247         countersignatory_keys_conv.is_owned = false;
39248         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
39249         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
39250         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
39251         return (int64_t)ret_conv;
39252 }
39253
39254 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) {
39255         LDKPublicKey revocation_key_ref;
39256         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
39257         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
39258         LDKPublicKey broadcaster_delayed_payment_key_ref;
39259         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
39260         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
39261         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
39262         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39263         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39264         CVec_u8Z_free(ret_var);
39265         return ret_arr;
39266 }
39267
39268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39269         LDKHTLCOutputInCommitment this_obj_conv;
39270         this_obj_conv.inner = (void*)(this_obj & (~1));
39271         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39273         HTLCOutputInCommitment_free(this_obj_conv);
39274 }
39275
39276 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
39277         LDKHTLCOutputInCommitment this_ptr_conv;
39278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39279         this_ptr_conv.is_owned = false;
39280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39281         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
39282         return ret_conv;
39283 }
39284
39285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39286         LDKHTLCOutputInCommitment this_ptr_conv;
39287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39288         this_ptr_conv.is_owned = false;
39289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39290         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
39291 }
39292
39293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39294         LDKHTLCOutputInCommitment this_ptr_conv;
39295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39296         this_ptr_conv.is_owned = false;
39297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39298         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
39299         return ret_conv;
39300 }
39301
39302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39303         LDKHTLCOutputInCommitment this_ptr_conv;
39304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39305         this_ptr_conv.is_owned = false;
39306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39307         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
39308 }
39309
39310 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
39311         LDKHTLCOutputInCommitment this_ptr_conv;
39312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39313         this_ptr_conv.is_owned = false;
39314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39315         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
39316         return ret_conv;
39317 }
39318
39319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39320         LDKHTLCOutputInCommitment this_ptr_conv;
39321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39322         this_ptr_conv.is_owned = false;
39323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39324         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
39325 }
39326
39327 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39328         LDKHTLCOutputInCommitment this_ptr_conv;
39329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39330         this_ptr_conv.is_owned = false;
39331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39332         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39333         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
39334         return ret_arr;
39335 }
39336
39337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39338         LDKHTLCOutputInCommitment this_ptr_conv;
39339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39340         this_ptr_conv.is_owned = false;
39341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39342         LDKThirtyTwoBytes val_ref;
39343         CHECK((*env)->GetArrayLength(env, val) == 32);
39344         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39345         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
39346 }
39347
39348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
39349         LDKHTLCOutputInCommitment this_ptr_conv;
39350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39351         this_ptr_conv.is_owned = false;
39352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39353         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
39354         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
39355         int64_t ret_ref = (uintptr_t)ret_copy;
39356         return ret_ref;
39357 }
39358
39359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39360         LDKHTLCOutputInCommitment this_ptr_conv;
39361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39362         this_ptr_conv.is_owned = false;
39363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39364         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
39365         CHECK_ACCESS(val_ptr);
39366         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
39367         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
39368         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
39369 }
39370
39371 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) {
39372         LDKThirtyTwoBytes payment_hash_arg_ref;
39373         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
39374         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
39375         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
39376         CHECK_ACCESS(transaction_output_index_arg_ptr);
39377         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
39378         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
39379         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
39380         int64_t ret_ref = 0;
39381         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39382         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39384         ret_ref = (uintptr_t)ret_var.inner;
39385         if (ret_var.is_owned) {
39386                 ret_ref |= 1;
39387         }
39388         return ret_ref;
39389 }
39390
39391 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
39392         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
39393 int64_t ret_ref = 0;
39394 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39395 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39396 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39397 ret_ref = (uintptr_t)ret_var.inner;
39398 if (ret_var.is_owned) {
39399         ret_ref |= 1;
39400 }
39401         return ret_ref;
39402 }
39403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39404         LDKHTLCOutputInCommitment arg_conv;
39405         arg_conv.inner = (void*)(arg & (~1));
39406         arg_conv.is_owned = false;
39407         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39408         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
39409         return ret_conv;
39410 }
39411
39412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39413         LDKHTLCOutputInCommitment orig_conv;
39414         orig_conv.inner = (void*)(orig & (~1));
39415         orig_conv.is_owned = false;
39416         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39417         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
39418         int64_t ret_ref = 0;
39419         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39420         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39422         ret_ref = (uintptr_t)ret_var.inner;
39423         if (ret_var.is_owned) {
39424                 ret_ref |= 1;
39425         }
39426         return ret_ref;
39427 }
39428
39429 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
39430         LDKHTLCOutputInCommitment obj_conv;
39431         obj_conv.inner = (void*)(obj & (~1));
39432         obj_conv.is_owned = false;
39433         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39434         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
39435         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39436         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39437         CVec_u8Z_free(ret_var);
39438         return ret_arr;
39439 }
39440
39441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39442         LDKu8slice ser_ref;
39443         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39444         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39445         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
39446         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
39447         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39448         return (int64_t)ret_conv;
39449 }
39450
39451 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) {
39452         LDKHTLCOutputInCommitment htlc_conv;
39453         htlc_conv.inner = (void*)(htlc & (~1));
39454         htlc_conv.is_owned = false;
39455         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
39456         LDKTxCreationKeys keys_conv;
39457         keys_conv.inner = (void*)(keys & (~1));
39458         keys_conv.is_owned = false;
39459         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
39460         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
39461         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39462         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39463         CVec_u8Z_free(ret_var);
39464         return ret_arr;
39465 }
39466
39467 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
39468         LDKPublicKey broadcaster_ref;
39469         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
39470         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
39471         LDKPublicKey countersignatory_ref;
39472         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
39473         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
39474         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
39475         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39476         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39477         CVec_u8Z_free(ret_var);
39478         return ret_arr;
39479 }
39480
39481 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) {
39482         unsigned char commitment_txid_arr[32];
39483         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
39484         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
39485         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
39486         LDKHTLCOutputInCommitment htlc_conv;
39487         htlc_conv.inner = (void*)(htlc & (~1));
39488         htlc_conv.is_owned = false;
39489         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
39490         LDKPublicKey broadcaster_delayed_payment_key_ref;
39491         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
39492         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
39493         LDKPublicKey revocation_key_ref;
39494         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
39495         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
39496         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);
39497         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39498         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39499         Transaction_free(ret_var);
39500         return ret_arr;
39501 }
39502
39503 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
39504         LDKPublicKey funding_pubkey_ref;
39505         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
39506         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
39507         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
39508         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39509         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39510         CVec_u8Z_free(ret_var);
39511         return ret_arr;
39512 }
39513
39514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39515         LDKChannelTransactionParameters this_obj_conv;
39516         this_obj_conv.inner = (void*)(this_obj & (~1));
39517         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39519         ChannelTransactionParameters_free(this_obj_conv);
39520 }
39521
39522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
39523         LDKChannelTransactionParameters this_ptr_conv;
39524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39525         this_ptr_conv.is_owned = false;
39526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39527         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
39528         int64_t ret_ref = 0;
39529         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39530         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39532         ret_ref = (uintptr_t)ret_var.inner;
39533         if (ret_var.is_owned) {
39534                 ret_ref |= 1;
39535         }
39536         return ret_ref;
39537 }
39538
39539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39540         LDKChannelTransactionParameters this_ptr_conv;
39541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39542         this_ptr_conv.is_owned = false;
39543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39544         LDKChannelPublicKeys val_conv;
39545         val_conv.inner = (void*)(val & (~1));
39546         val_conv.is_owned = (val & 1) || (val == 0);
39547         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39548         val_conv = ChannelPublicKeys_clone(&val_conv);
39549         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
39550 }
39551
39552 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
39553         LDKChannelTransactionParameters this_ptr_conv;
39554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39555         this_ptr_conv.is_owned = false;
39556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39557         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
39558         return ret_conv;
39559 }
39560
39561 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) {
39562         LDKChannelTransactionParameters this_ptr_conv;
39563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39564         this_ptr_conv.is_owned = false;
39565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39566         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
39567 }
39568
39569 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
39570         LDKChannelTransactionParameters this_ptr_conv;
39571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39572         this_ptr_conv.is_owned = false;
39573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39574         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
39575         return ret_conv;
39576 }
39577
39578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39579         LDKChannelTransactionParameters this_ptr_conv;
39580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39581         this_ptr_conv.is_owned = false;
39582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39583         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
39584 }
39585
39586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
39587         LDKChannelTransactionParameters this_ptr_conv;
39588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39589         this_ptr_conv.is_owned = false;
39590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39591         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
39592         int64_t ret_ref = 0;
39593         if ((uintptr_t)ret_var.inner > 4096) {
39594                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39595                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39596         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39597                 ret_ref = (uintptr_t)ret_var.inner;
39598                 if (ret_var.is_owned) {
39599                         ret_ref |= 1;
39600                 }
39601         }
39602         return ret_ref;
39603 }
39604
39605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39606         LDKChannelTransactionParameters this_ptr_conv;
39607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39608         this_ptr_conv.is_owned = false;
39609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39610         LDKCounterpartyChannelTransactionParameters val_conv;
39611         val_conv.inner = (void*)(val & (~1));
39612         val_conv.is_owned = (val & 1) || (val == 0);
39613         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39614         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
39615         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
39616 }
39617
39618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39619         LDKChannelTransactionParameters this_ptr_conv;
39620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39621         this_ptr_conv.is_owned = false;
39622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39623         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
39624         int64_t ret_ref = 0;
39625         if ((uintptr_t)ret_var.inner > 4096) {
39626                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39627                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39629                 ret_ref = (uintptr_t)ret_var.inner;
39630                 if (ret_var.is_owned) {
39631                         ret_ref |= 1;
39632                 }
39633         }
39634         return ret_ref;
39635 }
39636
39637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39638         LDKChannelTransactionParameters this_ptr_conv;
39639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39640         this_ptr_conv.is_owned = false;
39641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39642         LDKOutPoint val_conv;
39643         val_conv.inner = (void*)(val & (~1));
39644         val_conv.is_owned = (val & 1) || (val == 0);
39645         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39646         val_conv = OutPoint_clone(&val_conv);
39647         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
39648 }
39649
39650 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
39651         LDKChannelTransactionParameters this_ptr_conv;
39652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39653         this_ptr_conv.is_owned = false;
39654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39655         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
39656         return ret_conv;
39657 }
39658
39659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
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         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
39665         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
39666 }
39667
39668 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) {
39669         LDKChannelPublicKeys holder_pubkeys_arg_conv;
39670         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
39671         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
39672         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
39673         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
39674         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
39675         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
39676         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
39677         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
39678         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
39679         LDKOutPoint funding_outpoint_arg_conv;
39680         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
39681         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
39682         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
39683         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
39684         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
39685         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);
39686         int64_t ret_ref = 0;
39687         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39688         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39690         ret_ref = (uintptr_t)ret_var.inner;
39691         if (ret_var.is_owned) {
39692                 ret_ref |= 1;
39693         }
39694         return ret_ref;
39695 }
39696
39697 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
39698         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
39699 int64_t ret_ref = 0;
39700 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39701 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39702 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39703 ret_ref = (uintptr_t)ret_var.inner;
39704 if (ret_var.is_owned) {
39705         ret_ref |= 1;
39706 }
39707         return ret_ref;
39708 }
39709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39710         LDKChannelTransactionParameters arg_conv;
39711         arg_conv.inner = (void*)(arg & (~1));
39712         arg_conv.is_owned = false;
39713         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39714         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
39715         return ret_conv;
39716 }
39717
39718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39719         LDKChannelTransactionParameters orig_conv;
39720         orig_conv.inner = (void*)(orig & (~1));
39721         orig_conv.is_owned = false;
39722         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39723         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
39724         int64_t ret_ref = 0;
39725         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39726         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39728         ret_ref = (uintptr_t)ret_var.inner;
39729         if (ret_var.is_owned) {
39730                 ret_ref |= 1;
39731         }
39732         return ret_ref;
39733 }
39734
39735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39736         LDKCounterpartyChannelTransactionParameters this_obj_conv;
39737         this_obj_conv.inner = (void*)(this_obj & (~1));
39738         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39740         CounterpartyChannelTransactionParameters_free(this_obj_conv);
39741 }
39742
39743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
39744         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39746         this_ptr_conv.is_owned = false;
39747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39748         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
39749         int64_t ret_ref = 0;
39750         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39751         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39753         ret_ref = (uintptr_t)ret_var.inner;
39754         if (ret_var.is_owned) {
39755                 ret_ref |= 1;
39756         }
39757         return ret_ref;
39758 }
39759
39760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39761         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39763         this_ptr_conv.is_owned = false;
39764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39765         LDKChannelPublicKeys val_conv;
39766         val_conv.inner = (void*)(val & (~1));
39767         val_conv.is_owned = (val & 1) || (val == 0);
39768         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39769         val_conv = ChannelPublicKeys_clone(&val_conv);
39770         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
39771 }
39772
39773 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
39774         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39776         this_ptr_conv.is_owned = false;
39777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39778         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
39779         return ret_conv;
39780 }
39781
39782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
39783         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39785         this_ptr_conv.is_owned = false;
39786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39787         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
39788 }
39789
39790 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) {
39791         LDKChannelPublicKeys pubkeys_arg_conv;
39792         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
39793         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
39794         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
39795         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
39796         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
39797         int64_t ret_ref = 0;
39798         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39799         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39801         ret_ref = (uintptr_t)ret_var.inner;
39802         if (ret_var.is_owned) {
39803                 ret_ref |= 1;
39804         }
39805         return ret_ref;
39806 }
39807
39808 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
39809         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
39810 int64_t ret_ref = 0;
39811 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39812 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39813 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39814 ret_ref = (uintptr_t)ret_var.inner;
39815 if (ret_var.is_owned) {
39816         ret_ref |= 1;
39817 }
39818         return ret_ref;
39819 }
39820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39821         LDKCounterpartyChannelTransactionParameters arg_conv;
39822         arg_conv.inner = (void*)(arg & (~1));
39823         arg_conv.is_owned = false;
39824         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39825         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
39826         return ret_conv;
39827 }
39828
39829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39830         LDKCounterpartyChannelTransactionParameters orig_conv;
39831         orig_conv.inner = (void*)(orig & (~1));
39832         orig_conv.is_owned = false;
39833         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39834         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
39835         int64_t ret_ref = 0;
39836         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39837         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39839         ret_ref = (uintptr_t)ret_var.inner;
39840         if (ret_var.is_owned) {
39841                 ret_ref |= 1;
39842         }
39843         return ret_ref;
39844 }
39845
39846 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
39847         LDKChannelTransactionParameters this_arg_conv;
39848         this_arg_conv.inner = (void*)(this_arg & (~1));
39849         this_arg_conv.is_owned = false;
39850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39851         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
39852         return ret_conv;
39853 }
39854
39855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
39856         LDKChannelTransactionParameters this_arg_conv;
39857         this_arg_conv.inner = (void*)(this_arg & (~1));
39858         this_arg_conv.is_owned = false;
39859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39860         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
39861         int64_t ret_ref = 0;
39862         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39863         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39865         ret_ref = (uintptr_t)ret_var.inner;
39866         if (ret_var.is_owned) {
39867                 ret_ref |= 1;
39868         }
39869         return ret_ref;
39870 }
39871
39872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
39873         LDKChannelTransactionParameters this_arg_conv;
39874         this_arg_conv.inner = (void*)(this_arg & (~1));
39875         this_arg_conv.is_owned = false;
39876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39877         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
39878         int64_t ret_ref = 0;
39879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39882         ret_ref = (uintptr_t)ret_var.inner;
39883         if (ret_var.is_owned) {
39884                 ret_ref |= 1;
39885         }
39886         return ret_ref;
39887 }
39888
39889 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
39890         LDKCounterpartyChannelTransactionParameters obj_conv;
39891         obj_conv.inner = (void*)(obj & (~1));
39892         obj_conv.is_owned = false;
39893         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39894         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
39895         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39896         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39897         CVec_u8Z_free(ret_var);
39898         return ret_arr;
39899 }
39900
39901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39902         LDKu8slice ser_ref;
39903         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39904         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39905         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
39906         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
39907         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39908         return (int64_t)ret_conv;
39909 }
39910
39911 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
39912         LDKChannelTransactionParameters obj_conv;
39913         obj_conv.inner = (void*)(obj & (~1));
39914         obj_conv.is_owned = false;
39915         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39916         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
39917         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39918         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39919         CVec_u8Z_free(ret_var);
39920         return ret_arr;
39921 }
39922
39923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39924         LDKu8slice ser_ref;
39925         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39926         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39927         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
39928         *ret_conv = ChannelTransactionParameters_read(ser_ref);
39929         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39930         return (int64_t)ret_conv;
39931 }
39932
39933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39934         LDKDirectedChannelTransactionParameters this_obj_conv;
39935         this_obj_conv.inner = (void*)(this_obj & (~1));
39936         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39938         DirectedChannelTransactionParameters_free(this_obj_conv);
39939 }
39940
39941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
39942         LDKDirectedChannelTransactionParameters this_arg_conv;
39943         this_arg_conv.inner = (void*)(this_arg & (~1));
39944         this_arg_conv.is_owned = false;
39945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39946         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
39947         int64_t ret_ref = 0;
39948         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39949         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39951         ret_ref = (uintptr_t)ret_var.inner;
39952         if (ret_var.is_owned) {
39953                 ret_ref |= 1;
39954         }
39955         return ret_ref;
39956 }
39957
39958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
39959         LDKDirectedChannelTransactionParameters this_arg_conv;
39960         this_arg_conv.inner = (void*)(this_arg & (~1));
39961         this_arg_conv.is_owned = false;
39962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39963         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
39964         int64_t ret_ref = 0;
39965         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39966         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39968         ret_ref = (uintptr_t)ret_var.inner;
39969         if (ret_var.is_owned) {
39970                 ret_ref |= 1;
39971         }
39972         return ret_ref;
39973 }
39974
39975 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
39976         LDKDirectedChannelTransactionParameters this_arg_conv;
39977         this_arg_conv.inner = (void*)(this_arg & (~1));
39978         this_arg_conv.is_owned = false;
39979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39980         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
39981         return ret_conv;
39982 }
39983
39984 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
39985         LDKDirectedChannelTransactionParameters this_arg_conv;
39986         this_arg_conv.inner = (void*)(this_arg & (~1));
39987         this_arg_conv.is_owned = false;
39988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39989         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
39990         return ret_conv;
39991 }
39992
39993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
39994         LDKDirectedChannelTransactionParameters this_arg_conv;
39995         this_arg_conv.inner = (void*)(this_arg & (~1));
39996         this_arg_conv.is_owned = false;
39997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39998         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
39999         int64_t ret_ref = 0;
40000         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40001         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40003         ret_ref = (uintptr_t)ret_var.inner;
40004         if (ret_var.is_owned) {
40005                 ret_ref |= 1;
40006         }
40007         return ret_ref;
40008 }
40009
40010 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
40011         LDKDirectedChannelTransactionParameters this_arg_conv;
40012         this_arg_conv.inner = (void*)(this_arg & (~1));
40013         this_arg_conv.is_owned = false;
40014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40015         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
40016         return ret_conv;
40017 }
40018
40019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40020         LDKHolderCommitmentTransaction this_obj_conv;
40021         this_obj_conv.inner = (void*)(this_obj & (~1));
40022         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40024         HolderCommitmentTransaction_free(this_obj_conv);
40025 }
40026
40027 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
40028         LDKHolderCommitmentTransaction this_ptr_conv;
40029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40030         this_ptr_conv.is_owned = false;
40031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40032         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
40033         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
40034         return ret_arr;
40035 }
40036
40037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40038         LDKHolderCommitmentTransaction this_ptr_conv;
40039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40040         this_ptr_conv.is_owned = false;
40041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40042         LDKSignature val_ref;
40043         CHECK((*env)->GetArrayLength(env, val) == 64);
40044         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
40045         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
40046 }
40047
40048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
40049         LDKHolderCommitmentTransaction this_ptr_conv;
40050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40051         this_ptr_conv.is_owned = false;
40052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40053         LDKCVec_SignatureZ val_constr;
40054         val_constr.datalen = (*env)->GetArrayLength(env, val);
40055         if (val_constr.datalen > 0)
40056                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
40057         else
40058                 val_constr.data = NULL;
40059         for (size_t i = 0; i < val_constr.datalen; i++) {
40060                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
40061                 LDKSignature val_conv_8_ref;
40062                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
40063                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
40064                 val_constr.data[i] = val_conv_8_ref;
40065         }
40066         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
40067 }
40068
40069 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
40070         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40082         LDKHolderCommitmentTransaction arg_conv;
40083         arg_conv.inner = (void*)(arg & (~1));
40084         arg_conv.is_owned = false;
40085         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40086         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
40087         return ret_conv;
40088 }
40089
40090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40091         LDKHolderCommitmentTransaction orig_conv;
40092         orig_conv.inner = (void*)(orig & (~1));
40093         orig_conv.is_owned = false;
40094         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40095         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
40096         int64_t ret_ref = 0;
40097         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40098         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40100         ret_ref = (uintptr_t)ret_var.inner;
40101         if (ret_var.is_owned) {
40102                 ret_ref |= 1;
40103         }
40104         return ret_ref;
40105 }
40106
40107 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
40108         LDKHolderCommitmentTransaction obj_conv;
40109         obj_conv.inner = (void*)(obj & (~1));
40110         obj_conv.is_owned = false;
40111         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40112         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
40113         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40114         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40115         CVec_u8Z_free(ret_var);
40116         return ret_arr;
40117 }
40118
40119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40120         LDKu8slice ser_ref;
40121         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40122         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40123         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
40124         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
40125         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40126         return (int64_t)ret_conv;
40127 }
40128
40129 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) {
40130         LDKCommitmentTransaction commitment_tx_conv;
40131         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
40132         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
40133         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
40134         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
40135         LDKSignature counterparty_sig_ref;
40136         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
40137         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
40138         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
40139         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
40140         if (counterparty_htlc_sigs_constr.datalen > 0)
40141                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
40142         else
40143                 counterparty_htlc_sigs_constr.data = NULL;
40144         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
40145                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
40146                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
40147                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
40148                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
40149                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
40150         }
40151         LDKPublicKey holder_funding_key_ref;
40152         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
40153         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
40154         LDKPublicKey counterparty_funding_key_ref;
40155         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
40156         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
40157         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
40158         int64_t ret_ref = 0;
40159         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40160         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40162         ret_ref = (uintptr_t)ret_var.inner;
40163         if (ret_var.is_owned) {
40164                 ret_ref |= 1;
40165         }
40166         return ret_ref;
40167 }
40168
40169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40170         LDKBuiltCommitmentTransaction this_obj_conv;
40171         this_obj_conv.inner = (void*)(this_obj & (~1));
40172         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40174         BuiltCommitmentTransaction_free(this_obj_conv);
40175 }
40176
40177 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
40178         LDKBuiltCommitmentTransaction this_ptr_conv;
40179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40180         this_ptr_conv.is_owned = false;
40181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40182         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
40183         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40184         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40185         Transaction_free(ret_var);
40186         return ret_arr;
40187 }
40188
40189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40190         LDKBuiltCommitmentTransaction this_ptr_conv;
40191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40192         this_ptr_conv.is_owned = false;
40193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40194         LDKTransaction val_ref;
40195         val_ref.datalen = (*env)->GetArrayLength(env, val);
40196         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
40197         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
40198         val_ref.data_is_owned = true;
40199         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
40200 }
40201
40202 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
40203         LDKBuiltCommitmentTransaction this_ptr_conv;
40204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40205         this_ptr_conv.is_owned = false;
40206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40207         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40208         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
40209         return ret_arr;
40210 }
40211
40212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40213         LDKBuiltCommitmentTransaction this_ptr_conv;
40214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40215         this_ptr_conv.is_owned = false;
40216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40217         LDKThirtyTwoBytes val_ref;
40218         CHECK((*env)->GetArrayLength(env, val) == 32);
40219         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
40220         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
40221 }
40222
40223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
40224         LDKTransaction transaction_arg_ref;
40225         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
40226         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
40227         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
40228         transaction_arg_ref.data_is_owned = true;
40229         LDKThirtyTwoBytes txid_arg_ref;
40230         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
40231         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
40232         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
40233         int64_t ret_ref = 0;
40234         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40235         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40237         ret_ref = (uintptr_t)ret_var.inner;
40238         if (ret_var.is_owned) {
40239                 ret_ref |= 1;
40240         }
40241         return ret_ref;
40242 }
40243
40244 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
40245         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
40246 int64_t ret_ref = 0;
40247 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40248 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40249 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40250 ret_ref = (uintptr_t)ret_var.inner;
40251 if (ret_var.is_owned) {
40252         ret_ref |= 1;
40253 }
40254         return ret_ref;
40255 }
40256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40257         LDKBuiltCommitmentTransaction arg_conv;
40258         arg_conv.inner = (void*)(arg & (~1));
40259         arg_conv.is_owned = false;
40260         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40261         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
40262         return ret_conv;
40263 }
40264
40265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40266         LDKBuiltCommitmentTransaction orig_conv;
40267         orig_conv.inner = (void*)(orig & (~1));
40268         orig_conv.is_owned = false;
40269         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40270         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
40271         int64_t ret_ref = 0;
40272         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40273         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40275         ret_ref = (uintptr_t)ret_var.inner;
40276         if (ret_var.is_owned) {
40277                 ret_ref |= 1;
40278         }
40279         return ret_ref;
40280 }
40281
40282 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
40283         LDKBuiltCommitmentTransaction obj_conv;
40284         obj_conv.inner = (void*)(obj & (~1));
40285         obj_conv.is_owned = false;
40286         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40287         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
40288         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40289         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40290         CVec_u8Z_free(ret_var);
40291         return ret_arr;
40292 }
40293
40294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40295         LDKu8slice ser_ref;
40296         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40297         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40298         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
40299         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
40300         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40301         return (int64_t)ret_conv;
40302 }
40303
40304 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) {
40305         LDKBuiltCommitmentTransaction this_arg_conv;
40306         this_arg_conv.inner = (void*)(this_arg & (~1));
40307         this_arg_conv.is_owned = false;
40308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40309         LDKu8slice funding_redeemscript_ref;
40310         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
40311         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
40312         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40313         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
40314         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
40315         return ret_arr;
40316 }
40317
40318 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) {
40319         LDKBuiltCommitmentTransaction this_arg_conv;
40320         this_arg_conv.inner = (void*)(this_arg & (~1));
40321         this_arg_conv.is_owned = false;
40322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40323         unsigned char funding_key_arr[32];
40324         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
40325         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
40326         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
40327         LDKu8slice funding_redeemscript_ref;
40328         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
40329         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
40330         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
40331         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
40332         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
40333         return ret_arr;
40334 }
40335
40336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40337         LDKClosingTransaction this_obj_conv;
40338         this_obj_conv.inner = (void*)(this_obj & (~1));
40339         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40341         ClosingTransaction_free(this_obj_conv);
40342 }
40343
40344 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
40345         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
40346 int64_t ret_ref = 0;
40347 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40348 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40349 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40350 ret_ref = (uintptr_t)ret_var.inner;
40351 if (ret_var.is_owned) {
40352         ret_ref |= 1;
40353 }
40354         return ret_ref;
40355 }
40356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40357         LDKClosingTransaction arg_conv;
40358         arg_conv.inner = (void*)(arg & (~1));
40359         arg_conv.is_owned = false;
40360         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40361         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
40362         return ret_conv;
40363 }
40364
40365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40366         LDKClosingTransaction orig_conv;
40367         orig_conv.inner = (void*)(orig & (~1));
40368         orig_conv.is_owned = false;
40369         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40370         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
40371         int64_t ret_ref = 0;
40372         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40373         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40375         ret_ref = (uintptr_t)ret_var.inner;
40376         if (ret_var.is_owned) {
40377                 ret_ref |= 1;
40378         }
40379         return ret_ref;
40380 }
40381
40382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
40383         LDKClosingTransaction o_conv;
40384         o_conv.inner = (void*)(o & (~1));
40385         o_conv.is_owned = false;
40386         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40387         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
40388         return ret_conv;
40389 }
40390
40391 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) {
40392         LDKCVec_u8Z to_holder_script_ref;
40393         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
40394         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
40395         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
40396         LDKCVec_u8Z to_counterparty_script_ref;
40397         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
40398         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
40399         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
40400         LDKOutPoint funding_outpoint_conv;
40401         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
40402         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
40403         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
40404         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
40405         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
40406         int64_t ret_ref = 0;
40407         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40408         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40410         ret_ref = (uintptr_t)ret_var.inner;
40411         if (ret_var.is_owned) {
40412                 ret_ref |= 1;
40413         }
40414         return ret_ref;
40415 }
40416
40417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
40418         LDKClosingTransaction this_arg_conv;
40419         this_arg_conv.inner = (void*)(this_arg & (~1));
40420         this_arg_conv.is_owned = false;
40421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40422         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
40423         int64_t ret_ref = 0;
40424         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40425         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40427         ret_ref = (uintptr_t)ret_var.inner;
40428         if (ret_var.is_owned) {
40429                 ret_ref |= 1;
40430         }
40431         return ret_ref;
40432 }
40433
40434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
40435         LDKClosingTransaction this_arg_conv;
40436         this_arg_conv.inner = (void*)(this_arg & (~1));
40437         this_arg_conv.is_owned = false;
40438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40439         LDKOutPoint funding_outpoint_conv;
40440         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
40441         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
40442         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
40443         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
40444         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
40445         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
40446         return (int64_t)ret_conv;
40447 }
40448
40449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
40450         LDKClosingTransaction this_arg_conv;
40451         this_arg_conv.inner = (void*)(this_arg & (~1));
40452         this_arg_conv.is_owned = false;
40453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40454         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
40455         return ret_conv;
40456 }
40457
40458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
40459         LDKClosingTransaction this_arg_conv;
40460         this_arg_conv.inner = (void*)(this_arg & (~1));
40461         this_arg_conv.is_owned = false;
40462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40463         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
40464         return ret_conv;
40465 }
40466
40467 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40468         LDKClosingTransaction this_arg_conv;
40469         this_arg_conv.inner = (void*)(this_arg & (~1));
40470         this_arg_conv.is_owned = false;
40471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40472         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
40473         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40474         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40475         return ret_arr;
40476 }
40477
40478 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40479         LDKClosingTransaction this_arg_conv;
40480         this_arg_conv.inner = (void*)(this_arg & (~1));
40481         this_arg_conv.is_owned = false;
40482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40483         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
40484         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40485         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40486         return ret_arr;
40487 }
40488
40489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40490         LDKTrustedClosingTransaction this_obj_conv;
40491         this_obj_conv.inner = (void*)(this_obj & (~1));
40492         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40494         TrustedClosingTransaction_free(this_obj_conv);
40495 }
40496
40497 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
40498         LDKTrustedClosingTransaction this_arg_conv;
40499         this_arg_conv.inner = (void*)(this_arg & (~1));
40500         this_arg_conv.is_owned = false;
40501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40502         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
40503         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40504         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40505         Transaction_free(ret_var);
40506         return ret_arr;
40507 }
40508
40509 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) {
40510         LDKTrustedClosingTransaction this_arg_conv;
40511         this_arg_conv.inner = (void*)(this_arg & (~1));
40512         this_arg_conv.is_owned = false;
40513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40514         LDKu8slice funding_redeemscript_ref;
40515         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
40516         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
40517         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40518         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
40519         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
40520         return ret_arr;
40521 }
40522
40523 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) {
40524         LDKTrustedClosingTransaction this_arg_conv;
40525         this_arg_conv.inner = (void*)(this_arg & (~1));
40526         this_arg_conv.is_owned = false;
40527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40528         unsigned char funding_key_arr[32];
40529         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
40530         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
40531         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
40532         LDKu8slice funding_redeemscript_ref;
40533         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
40534         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
40535         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
40536         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
40537         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
40538         return ret_arr;
40539 }
40540
40541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40542         LDKCommitmentTransaction this_obj_conv;
40543         this_obj_conv.inner = (void*)(this_obj & (~1));
40544         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40546         CommitmentTransaction_free(this_obj_conv);
40547 }
40548
40549 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
40550         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
40551 int64_t ret_ref = 0;
40552 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40553 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40554 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40555 ret_ref = (uintptr_t)ret_var.inner;
40556 if (ret_var.is_owned) {
40557         ret_ref |= 1;
40558 }
40559         return ret_ref;
40560 }
40561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40562         LDKCommitmentTransaction arg_conv;
40563         arg_conv.inner = (void*)(arg & (~1));
40564         arg_conv.is_owned = false;
40565         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40566         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
40567         return ret_conv;
40568 }
40569
40570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40571         LDKCommitmentTransaction orig_conv;
40572         orig_conv.inner = (void*)(orig & (~1));
40573         orig_conv.is_owned = false;
40574         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40575         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
40576         int64_t ret_ref = 0;
40577         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40578         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40580         ret_ref = (uintptr_t)ret_var.inner;
40581         if (ret_var.is_owned) {
40582                 ret_ref |= 1;
40583         }
40584         return ret_ref;
40585 }
40586
40587 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
40588         LDKCommitmentTransaction obj_conv;
40589         obj_conv.inner = (void*)(obj & (~1));
40590         obj_conv.is_owned = false;
40591         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40592         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
40593         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40594         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40595         CVec_u8Z_free(ret_var);
40596         return ret_arr;
40597 }
40598
40599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40600         LDKu8slice ser_ref;
40601         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40602         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40603         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
40604         *ret_conv = CommitmentTransaction_read(ser_ref);
40605         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40606         return (int64_t)ret_conv;
40607 }
40608
40609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
40610         LDKCommitmentTransaction this_arg_conv;
40611         this_arg_conv.inner = (void*)(this_arg & (~1));
40612         this_arg_conv.is_owned = false;
40613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40614         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
40615         return ret_conv;
40616 }
40617
40618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
40619         LDKCommitmentTransaction this_arg_conv;
40620         this_arg_conv.inner = (void*)(this_arg & (~1));
40621         this_arg_conv.is_owned = false;
40622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40623         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
40624         return ret_conv;
40625 }
40626
40627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
40628         LDKCommitmentTransaction this_arg_conv;
40629         this_arg_conv.inner = (void*)(this_arg & (~1));
40630         this_arg_conv.is_owned = false;
40631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40632         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
40633         return ret_conv;
40634 }
40635
40636 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
40637         LDKCommitmentTransaction this_arg_conv;
40638         this_arg_conv.inner = (void*)(this_arg & (~1));
40639         this_arg_conv.is_owned = false;
40640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40641         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
40642         return ret_conv;
40643 }
40644
40645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
40646         LDKCommitmentTransaction this_arg_conv;
40647         this_arg_conv.inner = (void*)(this_arg & (~1));
40648         this_arg_conv.is_owned = false;
40649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40650         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
40651         int64_t ret_ref = 0;
40652         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40653         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40655         ret_ref = (uintptr_t)ret_var.inner;
40656         if (ret_var.is_owned) {
40657                 ret_ref |= 1;
40658         }
40659         return ret_ref;
40660 }
40661
40662 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) {
40663         LDKCommitmentTransaction this_arg_conv;
40664         this_arg_conv.inner = (void*)(this_arg & (~1));
40665         this_arg_conv.is_owned = false;
40666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40667         LDKDirectedChannelTransactionParameters channel_parameters_conv;
40668         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
40669         channel_parameters_conv.is_owned = false;
40670         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
40671         LDKChannelPublicKeys broadcaster_keys_conv;
40672         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
40673         broadcaster_keys_conv.is_owned = false;
40674         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
40675         LDKChannelPublicKeys countersignatory_keys_conv;
40676         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
40677         countersignatory_keys_conv.is_owned = false;
40678         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
40679         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
40680         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
40681         return (int64_t)ret_conv;
40682 }
40683
40684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40685         LDKTrustedCommitmentTransaction this_obj_conv;
40686         this_obj_conv.inner = (void*)(this_obj & (~1));
40687         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40689         TrustedCommitmentTransaction_free(this_obj_conv);
40690 }
40691
40692 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
40693         LDKTrustedCommitmentTransaction this_arg_conv;
40694         this_arg_conv.inner = (void*)(this_arg & (~1));
40695         this_arg_conv.is_owned = false;
40696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40697         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40698         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
40699         return ret_arr;
40700 }
40701
40702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
40703         LDKTrustedCommitmentTransaction this_arg_conv;
40704         this_arg_conv.inner = (void*)(this_arg & (~1));
40705         this_arg_conv.is_owned = false;
40706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40707         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
40708         int64_t ret_ref = 0;
40709         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40710         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40712         ret_ref = (uintptr_t)ret_var.inner;
40713         if (ret_var.is_owned) {
40714                 ret_ref |= 1;
40715         }
40716         return ret_ref;
40717 }
40718
40719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
40720         LDKTrustedCommitmentTransaction this_arg_conv;
40721         this_arg_conv.inner = (void*)(this_arg & (~1));
40722         this_arg_conv.is_owned = false;
40723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40724         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
40725         int64_t ret_ref = 0;
40726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40729         ret_ref = (uintptr_t)ret_var.inner;
40730         if (ret_var.is_owned) {
40731                 ret_ref |= 1;
40732         }
40733         return ret_ref;
40734 }
40735
40736 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
40737         LDKTrustedCommitmentTransaction this_arg_conv;
40738         this_arg_conv.inner = (void*)(this_arg & (~1));
40739         this_arg_conv.is_owned = false;
40740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40741         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
40742         return ret_conv;
40743 }
40744
40745 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) {
40746         LDKTrustedCommitmentTransaction this_arg_conv;
40747         this_arg_conv.inner = (void*)(this_arg & (~1));
40748         this_arg_conv.is_owned = false;
40749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40750         unsigned char htlc_base_key_arr[32];
40751         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
40752         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
40753         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
40754         LDKDirectedChannelTransactionParameters channel_parameters_conv;
40755         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
40756         channel_parameters_conv.is_owned = false;
40757         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
40758         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
40759         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
40760         return (int64_t)ret_conv;
40761 }
40762
40763 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) {
40764         LDKPublicKey broadcaster_payment_basepoint_ref;
40765         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
40766         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
40767         LDKPublicKey countersignatory_payment_basepoint_ref;
40768         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
40769         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
40770         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
40771         return ret_conv;
40772 }
40773
40774 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40775         LDKInitFeatures a_conv;
40776         a_conv.inner = (void*)(a & (~1));
40777         a_conv.is_owned = false;
40778         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40779         LDKInitFeatures b_conv;
40780         b_conv.inner = (void*)(b & (~1));
40781         b_conv.is_owned = false;
40782         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40783         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
40784         return ret_conv;
40785 }
40786
40787 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40788         LDKNodeFeatures a_conv;
40789         a_conv.inner = (void*)(a & (~1));
40790         a_conv.is_owned = false;
40791         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40792         LDKNodeFeatures b_conv;
40793         b_conv.inner = (void*)(b & (~1));
40794         b_conv.is_owned = false;
40795         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40796         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
40797         return ret_conv;
40798 }
40799
40800 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40801         LDKChannelFeatures a_conv;
40802         a_conv.inner = (void*)(a & (~1));
40803         a_conv.is_owned = false;
40804         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40805         LDKChannelFeatures b_conv;
40806         b_conv.inner = (void*)(b & (~1));
40807         b_conv.is_owned = false;
40808         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40809         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
40810         return ret_conv;
40811 }
40812
40813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40814         LDKInvoiceFeatures a_conv;
40815         a_conv.inner = (void*)(a & (~1));
40816         a_conv.is_owned = false;
40817         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40818         LDKInvoiceFeatures b_conv;
40819         b_conv.inner = (void*)(b & (~1));
40820         b_conv.is_owned = false;
40821         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40822         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
40823         return ret_conv;
40824 }
40825
40826 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40827         LDKChannelTypeFeatures a_conv;
40828         a_conv.inner = (void*)(a & (~1));
40829         a_conv.is_owned = false;
40830         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40831         LDKChannelTypeFeatures b_conv;
40832         b_conv.inner = (void*)(b & (~1));
40833         b_conv.is_owned = false;
40834         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40835         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
40836         return ret_conv;
40837 }
40838
40839 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
40840         LDKInitFeatures ret_var = InitFeatures_clone(arg);
40841 int64_t ret_ref = 0;
40842 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40843 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40844 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40845 ret_ref = (uintptr_t)ret_var.inner;
40846 if (ret_var.is_owned) {
40847         ret_ref |= 1;
40848 }
40849         return ret_ref;
40850 }
40851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40852         LDKInitFeatures arg_conv;
40853         arg_conv.inner = (void*)(arg & (~1));
40854         arg_conv.is_owned = false;
40855         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40856         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
40857         return ret_conv;
40858 }
40859
40860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40861         LDKInitFeatures orig_conv;
40862         orig_conv.inner = (void*)(orig & (~1));
40863         orig_conv.is_owned = false;
40864         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40865         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
40866         int64_t ret_ref = 0;
40867         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40868         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40870         ret_ref = (uintptr_t)ret_var.inner;
40871         if (ret_var.is_owned) {
40872                 ret_ref |= 1;
40873         }
40874         return ret_ref;
40875 }
40876
40877 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
40878         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
40879 int64_t ret_ref = 0;
40880 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40881 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40882 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40883 ret_ref = (uintptr_t)ret_var.inner;
40884 if (ret_var.is_owned) {
40885         ret_ref |= 1;
40886 }
40887         return ret_ref;
40888 }
40889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40890         LDKNodeFeatures arg_conv;
40891         arg_conv.inner = (void*)(arg & (~1));
40892         arg_conv.is_owned = false;
40893         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40894         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
40895         return ret_conv;
40896 }
40897
40898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40899         LDKNodeFeatures orig_conv;
40900         orig_conv.inner = (void*)(orig & (~1));
40901         orig_conv.is_owned = false;
40902         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40903         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
40904         int64_t ret_ref = 0;
40905         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40906         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40908         ret_ref = (uintptr_t)ret_var.inner;
40909         if (ret_var.is_owned) {
40910                 ret_ref |= 1;
40911         }
40912         return ret_ref;
40913 }
40914
40915 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
40916         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
40917 int64_t ret_ref = 0;
40918 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40919 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40920 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40921 ret_ref = (uintptr_t)ret_var.inner;
40922 if (ret_var.is_owned) {
40923         ret_ref |= 1;
40924 }
40925         return ret_ref;
40926 }
40927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40928         LDKChannelFeatures arg_conv;
40929         arg_conv.inner = (void*)(arg & (~1));
40930         arg_conv.is_owned = false;
40931         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40932         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
40933         return ret_conv;
40934 }
40935
40936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40937         LDKChannelFeatures orig_conv;
40938         orig_conv.inner = (void*)(orig & (~1));
40939         orig_conv.is_owned = false;
40940         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40941         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
40942         int64_t ret_ref = 0;
40943         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40944         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40946         ret_ref = (uintptr_t)ret_var.inner;
40947         if (ret_var.is_owned) {
40948                 ret_ref |= 1;
40949         }
40950         return ret_ref;
40951 }
40952
40953 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
40954         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
40955 int64_t ret_ref = 0;
40956 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40957 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40958 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40959 ret_ref = (uintptr_t)ret_var.inner;
40960 if (ret_var.is_owned) {
40961         ret_ref |= 1;
40962 }
40963         return ret_ref;
40964 }
40965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40966         LDKInvoiceFeatures arg_conv;
40967         arg_conv.inner = (void*)(arg & (~1));
40968         arg_conv.is_owned = false;
40969         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40970         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
40971         return ret_conv;
40972 }
40973
40974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40975         LDKInvoiceFeatures orig_conv;
40976         orig_conv.inner = (void*)(orig & (~1));
40977         orig_conv.is_owned = false;
40978         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40979         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
40980         int64_t ret_ref = 0;
40981         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40982         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40983         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40984         ret_ref = (uintptr_t)ret_var.inner;
40985         if (ret_var.is_owned) {
40986                 ret_ref |= 1;
40987         }
40988         return ret_ref;
40989 }
40990
40991 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
40992         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
40993 int64_t ret_ref = 0;
40994 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40995 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40996 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40997 ret_ref = (uintptr_t)ret_var.inner;
40998 if (ret_var.is_owned) {
40999         ret_ref |= 1;
41000 }
41001         return ret_ref;
41002 }
41003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41004         LDKChannelTypeFeatures arg_conv;
41005         arg_conv.inner = (void*)(arg & (~1));
41006         arg_conv.is_owned = false;
41007         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41008         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
41009         return ret_conv;
41010 }
41011
41012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41013         LDKChannelTypeFeatures orig_conv;
41014         orig_conv.inner = (void*)(orig & (~1));
41015         orig_conv.is_owned = false;
41016         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41017         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
41018         int64_t ret_ref = 0;
41019         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41020         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41021         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41022         ret_ref = (uintptr_t)ret_var.inner;
41023         if (ret_var.is_owned) {
41024                 ret_ref |= 1;
41025         }
41026         return ret_ref;
41027 }
41028
41029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41030         LDKInitFeatures this_obj_conv;
41031         this_obj_conv.inner = (void*)(this_obj & (~1));
41032         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41034         InitFeatures_free(this_obj_conv);
41035 }
41036
41037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41038         LDKNodeFeatures this_obj_conv;
41039         this_obj_conv.inner = (void*)(this_obj & (~1));
41040         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41042         NodeFeatures_free(this_obj_conv);
41043 }
41044
41045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41046         LDKChannelFeatures this_obj_conv;
41047         this_obj_conv.inner = (void*)(this_obj & (~1));
41048         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41050         ChannelFeatures_free(this_obj_conv);
41051 }
41052
41053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41054         LDKInvoiceFeatures this_obj_conv;
41055         this_obj_conv.inner = (void*)(this_obj & (~1));
41056         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41058         InvoiceFeatures_free(this_obj_conv);
41059 }
41060
41061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41062         LDKChannelTypeFeatures this_obj_conv;
41063         this_obj_conv.inner = (void*)(this_obj & (~1));
41064         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41066         ChannelTypeFeatures_free(this_obj_conv);
41067 }
41068
41069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
41070         LDKInitFeatures ret_var = InitFeatures_empty();
41071         int64_t ret_ref = 0;
41072         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41073         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41075         ret_ref = (uintptr_t)ret_var.inner;
41076         if (ret_var.is_owned) {
41077                 ret_ref |= 1;
41078         }
41079         return ret_ref;
41080 }
41081
41082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
41083         LDKInitFeatures ret_var = InitFeatures_known();
41084         int64_t ret_ref = 0;
41085         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41086         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41087         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41088         ret_ref = (uintptr_t)ret_var.inner;
41089         if (ret_var.is_owned) {
41090                 ret_ref |= 1;
41091         }
41092         return ret_ref;
41093 }
41094
41095 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41096         LDKInitFeatures this_arg_conv;
41097         this_arg_conv.inner = (void*)(this_arg & (~1));
41098         this_arg_conv.is_owned = false;
41099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41100         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
41101         return ret_conv;
41102 }
41103
41104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
41105         LDKNodeFeatures ret_var = NodeFeatures_empty();
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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
41118         LDKNodeFeatures ret_var = NodeFeatures_known();
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
41130 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41131         LDKNodeFeatures this_arg_conv;
41132         this_arg_conv.inner = (void*)(this_arg & (~1));
41133         this_arg_conv.is_owned = false;
41134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41135         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
41136         return ret_conv;
41137 }
41138
41139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
41140         LDKChannelFeatures ret_var = ChannelFeatures_empty();
41141         int64_t ret_ref = 0;
41142         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41143         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41145         ret_ref = (uintptr_t)ret_var.inner;
41146         if (ret_var.is_owned) {
41147                 ret_ref |= 1;
41148         }
41149         return ret_ref;
41150 }
41151
41152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
41153         LDKChannelFeatures ret_var = ChannelFeatures_known();
41154         int64_t ret_ref = 0;
41155         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41156         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41158         ret_ref = (uintptr_t)ret_var.inner;
41159         if (ret_var.is_owned) {
41160                 ret_ref |= 1;
41161         }
41162         return ret_ref;
41163 }
41164
41165 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41166         LDKChannelFeatures this_arg_conv;
41167         this_arg_conv.inner = (void*)(this_arg & (~1));
41168         this_arg_conv.is_owned = false;
41169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41170         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
41171         return ret_conv;
41172 }
41173
41174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
41175         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
41176         int64_t ret_ref = 0;
41177         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41178         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41180         ret_ref = (uintptr_t)ret_var.inner;
41181         if (ret_var.is_owned) {
41182                 ret_ref |= 1;
41183         }
41184         return ret_ref;
41185 }
41186
41187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
41188         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
41189         int64_t ret_ref = 0;
41190         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41191         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41193         ret_ref = (uintptr_t)ret_var.inner;
41194         if (ret_var.is_owned) {
41195                 ret_ref |= 1;
41196         }
41197         return ret_ref;
41198 }
41199
41200 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41201         LDKInvoiceFeatures this_arg_conv;
41202         this_arg_conv.inner = (void*)(this_arg & (~1));
41203         this_arg_conv.is_owned = false;
41204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41205         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
41206         return ret_conv;
41207 }
41208
41209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
41210         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
41211         int64_t ret_ref = 0;
41212         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41213         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41215         ret_ref = (uintptr_t)ret_var.inner;
41216         if (ret_var.is_owned) {
41217                 ret_ref |= 1;
41218         }
41219         return ret_ref;
41220 }
41221
41222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1known(JNIEnv *env, jclass clz) {
41223         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
41224         int64_t ret_ref = 0;
41225         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41226         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41228         ret_ref = (uintptr_t)ret_var.inner;
41229         if (ret_var.is_owned) {
41230                 ret_ref |= 1;
41231         }
41232         return ret_ref;
41233 }
41234
41235 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41236         LDKChannelTypeFeatures this_arg_conv;
41237         this_arg_conv.inner = (void*)(this_arg & (~1));
41238         this_arg_conv.is_owned = false;
41239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41240         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
41241         return ret_conv;
41242 }
41243
41244 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41245         LDKInitFeatures obj_conv;
41246         obj_conv.inner = (void*)(obj & (~1));
41247         obj_conv.is_owned = false;
41248         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41249         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
41250         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41251         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41252         CVec_u8Z_free(ret_var);
41253         return ret_arr;
41254 }
41255
41256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41257         LDKu8slice ser_ref;
41258         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41259         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41260         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
41261         *ret_conv = InitFeatures_read(ser_ref);
41262         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41263         return (int64_t)ret_conv;
41264 }
41265
41266 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41267         LDKChannelFeatures obj_conv;
41268         obj_conv.inner = (void*)(obj & (~1));
41269         obj_conv.is_owned = false;
41270         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41271         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
41272         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41273         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41274         CVec_u8Z_free(ret_var);
41275         return ret_arr;
41276 }
41277
41278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41279         LDKu8slice ser_ref;
41280         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41281         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41282         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
41283         *ret_conv = ChannelFeatures_read(ser_ref);
41284         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41285         return (int64_t)ret_conv;
41286 }
41287
41288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41289         LDKNodeFeatures obj_conv;
41290         obj_conv.inner = (void*)(obj & (~1));
41291         obj_conv.is_owned = false;
41292         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41293         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
41294         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41295         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41296         CVec_u8Z_free(ret_var);
41297         return ret_arr;
41298 }
41299
41300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41301         LDKu8slice ser_ref;
41302         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41303         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41304         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
41305         *ret_conv = NodeFeatures_read(ser_ref);
41306         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41307         return (int64_t)ret_conv;
41308 }
41309
41310 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41311         LDKInvoiceFeatures obj_conv;
41312         obj_conv.inner = (void*)(obj & (~1));
41313         obj_conv.is_owned = false;
41314         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41315         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
41316         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41317         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41318         CVec_u8Z_free(ret_var);
41319         return ret_arr;
41320 }
41321
41322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41323         LDKu8slice ser_ref;
41324         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41325         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41326         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
41327         *ret_conv = InvoiceFeatures_read(ser_ref);
41328         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41329         return (int64_t)ret_conv;
41330 }
41331
41332 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41333         LDKChannelTypeFeatures obj_conv;
41334         obj_conv.inner = (void*)(obj & (~1));
41335         obj_conv.is_owned = false;
41336         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41337         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
41338         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41339         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41340         CVec_u8Z_free(ret_var);
41341         return ret_arr;
41342 }
41343
41344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41345         LDKu8slice ser_ref;
41346         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41347         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41348         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
41349         *ret_conv = ChannelTypeFeatures_read(ser_ref);
41350         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41351         return (int64_t)ret_conv;
41352 }
41353
41354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41355         LDKInitFeatures this_arg_conv;
41356         this_arg_conv.inner = (void*)(this_arg & (~1));
41357         this_arg_conv.is_owned = false;
41358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41359         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
41360 }
41361
41362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41363         LDKInitFeatures this_arg_conv;
41364         this_arg_conv.inner = (void*)(this_arg & (~1));
41365         this_arg_conv.is_owned = false;
41366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41367         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
41368 }
41369
41370 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41371         LDKInitFeatures this_arg_conv;
41372         this_arg_conv.inner = (void*)(this_arg & (~1));
41373         this_arg_conv.is_owned = false;
41374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41375         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
41376         return ret_conv;
41377 }
41378
41379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41380         LDKNodeFeatures this_arg_conv;
41381         this_arg_conv.inner = (void*)(this_arg & (~1));
41382         this_arg_conv.is_owned = false;
41383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41384         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
41385 }
41386
41387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41388         LDKNodeFeatures this_arg_conv;
41389         this_arg_conv.inner = (void*)(this_arg & (~1));
41390         this_arg_conv.is_owned = false;
41391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41392         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
41393 }
41394
41395 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41396         LDKNodeFeatures this_arg_conv;
41397         this_arg_conv.inner = (void*)(this_arg & (~1));
41398         this_arg_conv.is_owned = false;
41399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41400         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
41401         return ret_conv;
41402 }
41403
41404 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41405         LDKInitFeatures this_arg_conv;
41406         this_arg_conv.inner = (void*)(this_arg & (~1));
41407         this_arg_conv.is_owned = false;
41408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41409         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
41410         return ret_conv;
41411 }
41412
41413 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41414         LDKNodeFeatures this_arg_conv;
41415         this_arg_conv.inner = (void*)(this_arg & (~1));
41416         this_arg_conv.is_owned = false;
41417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41418         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
41419         return ret_conv;
41420 }
41421
41422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41423         LDKInitFeatures this_arg_conv;
41424         this_arg_conv.inner = (void*)(this_arg & (~1));
41425         this_arg_conv.is_owned = false;
41426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41427         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
41428 }
41429
41430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41431         LDKInitFeatures this_arg_conv;
41432         this_arg_conv.inner = (void*)(this_arg & (~1));
41433         this_arg_conv.is_owned = false;
41434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41435         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
41436 }
41437
41438 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1initial_1routing_1sync(JNIEnv *env, jclass clz, int64_t this_arg) {
41439         LDKInitFeatures this_arg_conv;
41440         this_arg_conv.inner = (void*)(this_arg & (~1));
41441         this_arg_conv.is_owned = false;
41442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41443         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
41444         return ret_conv;
41445 }
41446
41447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41448         LDKInitFeatures this_arg_conv;
41449         this_arg_conv.inner = (void*)(this_arg & (~1));
41450         this_arg_conv.is_owned = false;
41451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41452         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
41453 }
41454
41455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41456         LDKInitFeatures this_arg_conv;
41457         this_arg_conv.inner = (void*)(this_arg & (~1));
41458         this_arg_conv.is_owned = false;
41459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41460         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
41461 }
41462
41463 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41464         LDKInitFeatures this_arg_conv;
41465         this_arg_conv.inner = (void*)(this_arg & (~1));
41466         this_arg_conv.is_owned = false;
41467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41468         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
41469         return ret_conv;
41470 }
41471
41472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41473         LDKNodeFeatures this_arg_conv;
41474         this_arg_conv.inner = (void*)(this_arg & (~1));
41475         this_arg_conv.is_owned = false;
41476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41477         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
41478 }
41479
41480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41481         LDKNodeFeatures 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         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
41486 }
41487
41488 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41489         LDKNodeFeatures 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         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
41494         return ret_conv;
41495 }
41496
41497 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41498         LDKInitFeatures this_arg_conv;
41499         this_arg_conv.inner = (void*)(this_arg & (~1));
41500         this_arg_conv.is_owned = false;
41501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41502         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
41503         return ret_conv;
41504 }
41505
41506 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41507         LDKNodeFeatures this_arg_conv;
41508         this_arg_conv.inner = (void*)(this_arg & (~1));
41509         this_arg_conv.is_owned = false;
41510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41511         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
41512         return ret_conv;
41513 }
41514
41515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41516         LDKInitFeatures this_arg_conv;
41517         this_arg_conv.inner = (void*)(this_arg & (~1));
41518         this_arg_conv.is_owned = false;
41519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41520         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
41521 }
41522
41523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41524         LDKInitFeatures this_arg_conv;
41525         this_arg_conv.inner = (void*)(this_arg & (~1));
41526         this_arg_conv.is_owned = false;
41527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41528         InitFeatures_set_gossip_queries_required(&this_arg_conv);
41529 }
41530
41531 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
41532         LDKInitFeatures this_arg_conv;
41533         this_arg_conv.inner = (void*)(this_arg & (~1));
41534         this_arg_conv.is_owned = false;
41535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41536         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
41537         return ret_conv;
41538 }
41539
41540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41541         LDKNodeFeatures this_arg_conv;
41542         this_arg_conv.inner = (void*)(this_arg & (~1));
41543         this_arg_conv.is_owned = false;
41544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41545         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
41546 }
41547
41548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41549         LDKNodeFeatures 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         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
41554 }
41555
41556 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
41557         LDKNodeFeatures 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         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
41562         return ret_conv;
41563 }
41564
41565 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
41566         LDKInitFeatures this_arg_conv;
41567         this_arg_conv.inner = (void*)(this_arg & (~1));
41568         this_arg_conv.is_owned = false;
41569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41570         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
41571         return ret_conv;
41572 }
41573
41574 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
41575         LDKNodeFeatures this_arg_conv;
41576         this_arg_conv.inner = (void*)(this_arg & (~1));
41577         this_arg_conv.is_owned = false;
41578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41579         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
41580         return ret_conv;
41581 }
41582
41583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41584         LDKInitFeatures this_arg_conv;
41585         this_arg_conv.inner = (void*)(this_arg & (~1));
41586         this_arg_conv.is_owned = false;
41587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41588         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
41589 }
41590
41591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41592         LDKInitFeatures this_arg_conv;
41593         this_arg_conv.inner = (void*)(this_arg & (~1));
41594         this_arg_conv.is_owned = false;
41595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41596         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
41597 }
41598
41599 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41600         LDKInitFeatures this_arg_conv;
41601         this_arg_conv.inner = (void*)(this_arg & (~1));
41602         this_arg_conv.is_owned = false;
41603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41604         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
41605         return ret_conv;
41606 }
41607
41608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41609         LDKNodeFeatures this_arg_conv;
41610         this_arg_conv.inner = (void*)(this_arg & (~1));
41611         this_arg_conv.is_owned = false;
41612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41613         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
41614 }
41615
41616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41617         LDKNodeFeatures this_arg_conv;
41618         this_arg_conv.inner = (void*)(this_arg & (~1));
41619         this_arg_conv.is_owned = false;
41620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41621         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
41622 }
41623
41624 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41625         LDKNodeFeatures this_arg_conv;
41626         this_arg_conv.inner = (void*)(this_arg & (~1));
41627         this_arg_conv.is_owned = false;
41628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41629         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
41630         return ret_conv;
41631 }
41632
41633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41634         LDKInvoiceFeatures this_arg_conv;
41635         this_arg_conv.inner = (void*)(this_arg & (~1));
41636         this_arg_conv.is_owned = false;
41637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41638         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
41639 }
41640
41641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41642         LDKInvoiceFeatures 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         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
41647 }
41648
41649 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41650         LDKInvoiceFeatures 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         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
41655         return ret_conv;
41656 }
41657
41658 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41659         LDKInitFeatures this_arg_conv;
41660         this_arg_conv.inner = (void*)(this_arg & (~1));
41661         this_arg_conv.is_owned = false;
41662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41663         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
41664         return ret_conv;
41665 }
41666
41667 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41668         LDKNodeFeatures this_arg_conv;
41669         this_arg_conv.inner = (void*)(this_arg & (~1));
41670         this_arg_conv.is_owned = false;
41671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41672         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
41673         return ret_conv;
41674 }
41675
41676 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41677         LDKInvoiceFeatures this_arg_conv;
41678         this_arg_conv.inner = (void*)(this_arg & (~1));
41679         this_arg_conv.is_owned = false;
41680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41681         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
41682         return ret_conv;
41683 }
41684
41685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41686         LDKInitFeatures this_arg_conv;
41687         this_arg_conv.inner = (void*)(this_arg & (~1));
41688         this_arg_conv.is_owned = false;
41689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41690         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
41691 }
41692
41693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41694         LDKInitFeatures this_arg_conv;
41695         this_arg_conv.inner = (void*)(this_arg & (~1));
41696         this_arg_conv.is_owned = false;
41697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41698         InitFeatures_set_static_remote_key_required(&this_arg_conv);
41699 }
41700
41701 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41702         LDKInitFeatures this_arg_conv;
41703         this_arg_conv.inner = (void*)(this_arg & (~1));
41704         this_arg_conv.is_owned = false;
41705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41706         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
41707         return ret_conv;
41708 }
41709
41710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41711         LDKNodeFeatures this_arg_conv;
41712         this_arg_conv.inner = (void*)(this_arg & (~1));
41713         this_arg_conv.is_owned = false;
41714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41715         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
41716 }
41717
41718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41719         LDKNodeFeatures this_arg_conv;
41720         this_arg_conv.inner = (void*)(this_arg & (~1));
41721         this_arg_conv.is_owned = false;
41722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41723         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
41724 }
41725
41726 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41727         LDKNodeFeatures this_arg_conv;
41728         this_arg_conv.inner = (void*)(this_arg & (~1));
41729         this_arg_conv.is_owned = false;
41730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41731         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
41732         return ret_conv;
41733 }
41734
41735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41736         LDKChannelTypeFeatures this_arg_conv;
41737         this_arg_conv.inner = (void*)(this_arg & (~1));
41738         this_arg_conv.is_owned = false;
41739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41740         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
41741 }
41742
41743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41744         LDKChannelTypeFeatures this_arg_conv;
41745         this_arg_conv.inner = (void*)(this_arg & (~1));
41746         this_arg_conv.is_owned = false;
41747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41748         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
41749 }
41750
41751 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41752         LDKChannelTypeFeatures this_arg_conv;
41753         this_arg_conv.inner = (void*)(this_arg & (~1));
41754         this_arg_conv.is_owned = false;
41755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41756         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
41757         return ret_conv;
41758 }
41759
41760 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41761         LDKInitFeatures this_arg_conv;
41762         this_arg_conv.inner = (void*)(this_arg & (~1));
41763         this_arg_conv.is_owned = false;
41764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41765         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
41766         return ret_conv;
41767 }
41768
41769 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41770         LDKNodeFeatures this_arg_conv;
41771         this_arg_conv.inner = (void*)(this_arg & (~1));
41772         this_arg_conv.is_owned = false;
41773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41774         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
41775         return ret_conv;
41776 }
41777
41778 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41779         LDKChannelTypeFeatures this_arg_conv;
41780         this_arg_conv.inner = (void*)(this_arg & (~1));
41781         this_arg_conv.is_owned = false;
41782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41783         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
41784         return ret_conv;
41785 }
41786
41787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41788         LDKInitFeatures this_arg_conv;
41789         this_arg_conv.inner = (void*)(this_arg & (~1));
41790         this_arg_conv.is_owned = false;
41791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41792         InitFeatures_set_payment_secret_optional(&this_arg_conv);
41793 }
41794
41795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41796         LDKInitFeatures this_arg_conv;
41797         this_arg_conv.inner = (void*)(this_arg & (~1));
41798         this_arg_conv.is_owned = false;
41799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41800         InitFeatures_set_payment_secret_required(&this_arg_conv);
41801 }
41802
41803 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41804         LDKInitFeatures this_arg_conv;
41805         this_arg_conv.inner = (void*)(this_arg & (~1));
41806         this_arg_conv.is_owned = false;
41807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41808         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
41809         return ret_conv;
41810 }
41811
41812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41813         LDKNodeFeatures this_arg_conv;
41814         this_arg_conv.inner = (void*)(this_arg & (~1));
41815         this_arg_conv.is_owned = false;
41816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41817         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
41818 }
41819
41820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41821         LDKNodeFeatures this_arg_conv;
41822         this_arg_conv.inner = (void*)(this_arg & (~1));
41823         this_arg_conv.is_owned = false;
41824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41825         NodeFeatures_set_payment_secret_required(&this_arg_conv);
41826 }
41827
41828 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41829         LDKNodeFeatures this_arg_conv;
41830         this_arg_conv.inner = (void*)(this_arg & (~1));
41831         this_arg_conv.is_owned = false;
41832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41833         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
41834         return ret_conv;
41835 }
41836
41837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41838         LDKInvoiceFeatures this_arg_conv;
41839         this_arg_conv.inner = (void*)(this_arg & (~1));
41840         this_arg_conv.is_owned = false;
41841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41842         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
41843 }
41844
41845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41846         LDKInvoiceFeatures this_arg_conv;
41847         this_arg_conv.inner = (void*)(this_arg & (~1));
41848         this_arg_conv.is_owned = false;
41849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41850         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
41851 }
41852
41853 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41854         LDKInvoiceFeatures this_arg_conv;
41855         this_arg_conv.inner = (void*)(this_arg & (~1));
41856         this_arg_conv.is_owned = false;
41857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41858         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
41859         return ret_conv;
41860 }
41861
41862 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41863         LDKInitFeatures this_arg_conv;
41864         this_arg_conv.inner = (void*)(this_arg & (~1));
41865         this_arg_conv.is_owned = false;
41866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41867         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
41868         return ret_conv;
41869 }
41870
41871 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41872         LDKNodeFeatures this_arg_conv;
41873         this_arg_conv.inner = (void*)(this_arg & (~1));
41874         this_arg_conv.is_owned = false;
41875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41876         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
41877         return ret_conv;
41878 }
41879
41880 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41881         LDKInvoiceFeatures this_arg_conv;
41882         this_arg_conv.inner = (void*)(this_arg & (~1));
41883         this_arg_conv.is_owned = false;
41884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41885         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
41886         return ret_conv;
41887 }
41888
41889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41890         LDKInitFeatures this_arg_conv;
41891         this_arg_conv.inner = (void*)(this_arg & (~1));
41892         this_arg_conv.is_owned = false;
41893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41894         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
41895 }
41896
41897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41898         LDKInitFeatures this_arg_conv;
41899         this_arg_conv.inner = (void*)(this_arg & (~1));
41900         this_arg_conv.is_owned = false;
41901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41902         InitFeatures_set_basic_mpp_required(&this_arg_conv);
41903 }
41904
41905 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41906         LDKInitFeatures this_arg_conv;
41907         this_arg_conv.inner = (void*)(this_arg & (~1));
41908         this_arg_conv.is_owned = false;
41909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41910         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
41911         return ret_conv;
41912 }
41913
41914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41915         LDKNodeFeatures this_arg_conv;
41916         this_arg_conv.inner = (void*)(this_arg & (~1));
41917         this_arg_conv.is_owned = false;
41918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41919         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
41920 }
41921
41922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41923         LDKNodeFeatures this_arg_conv;
41924         this_arg_conv.inner = (void*)(this_arg & (~1));
41925         this_arg_conv.is_owned = false;
41926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41927         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
41928 }
41929
41930 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41931         LDKNodeFeatures this_arg_conv;
41932         this_arg_conv.inner = (void*)(this_arg & (~1));
41933         this_arg_conv.is_owned = false;
41934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41935         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
41936         return ret_conv;
41937 }
41938
41939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41940         LDKInvoiceFeatures this_arg_conv;
41941         this_arg_conv.inner = (void*)(this_arg & (~1));
41942         this_arg_conv.is_owned = false;
41943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41944         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
41945 }
41946
41947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41948         LDKInvoiceFeatures this_arg_conv;
41949         this_arg_conv.inner = (void*)(this_arg & (~1));
41950         this_arg_conv.is_owned = false;
41951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41952         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
41953 }
41954
41955 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41956         LDKInvoiceFeatures this_arg_conv;
41957         this_arg_conv.inner = (void*)(this_arg & (~1));
41958         this_arg_conv.is_owned = false;
41959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41960         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
41961         return ret_conv;
41962 }
41963
41964 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41965         LDKInitFeatures this_arg_conv;
41966         this_arg_conv.inner = (void*)(this_arg & (~1));
41967         this_arg_conv.is_owned = false;
41968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41969         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
41970         return ret_conv;
41971 }
41972
41973 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41974         LDKNodeFeatures this_arg_conv;
41975         this_arg_conv.inner = (void*)(this_arg & (~1));
41976         this_arg_conv.is_owned = false;
41977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41978         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
41979         return ret_conv;
41980 }
41981
41982 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41983         LDKInvoiceFeatures this_arg_conv;
41984         this_arg_conv.inner = (void*)(this_arg & (~1));
41985         this_arg_conv.is_owned = false;
41986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41987         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
41988         return ret_conv;
41989 }
41990
41991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41992         LDKInitFeatures this_arg_conv;
41993         this_arg_conv.inner = (void*)(this_arg & (~1));
41994         this_arg_conv.is_owned = false;
41995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41996         InitFeatures_set_wumbo_optional(&this_arg_conv);
41997 }
41998
41999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42000         LDKInitFeatures this_arg_conv;
42001         this_arg_conv.inner = (void*)(this_arg & (~1));
42002         this_arg_conv.is_owned = false;
42003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42004         InitFeatures_set_wumbo_required(&this_arg_conv);
42005 }
42006
42007 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42008         LDKInitFeatures this_arg_conv;
42009         this_arg_conv.inner = (void*)(this_arg & (~1));
42010         this_arg_conv.is_owned = false;
42011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42012         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
42013         return ret_conv;
42014 }
42015
42016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42017         LDKNodeFeatures this_arg_conv;
42018         this_arg_conv.inner = (void*)(this_arg & (~1));
42019         this_arg_conv.is_owned = false;
42020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42021         NodeFeatures_set_wumbo_optional(&this_arg_conv);
42022 }
42023
42024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42025         LDKNodeFeatures this_arg_conv;
42026         this_arg_conv.inner = (void*)(this_arg & (~1));
42027         this_arg_conv.is_owned = false;
42028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42029         NodeFeatures_set_wumbo_required(&this_arg_conv);
42030 }
42031
42032 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42033         LDKNodeFeatures this_arg_conv;
42034         this_arg_conv.inner = (void*)(this_arg & (~1));
42035         this_arg_conv.is_owned = false;
42036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42037         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
42038         return ret_conv;
42039 }
42040
42041 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42042         LDKInitFeatures this_arg_conv;
42043         this_arg_conv.inner = (void*)(this_arg & (~1));
42044         this_arg_conv.is_owned = false;
42045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42046         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
42047         return ret_conv;
42048 }
42049
42050 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42051         LDKNodeFeatures this_arg_conv;
42052         this_arg_conv.inner = (void*)(this_arg & (~1));
42053         this_arg_conv.is_owned = false;
42054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42055         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
42056         return ret_conv;
42057 }
42058
42059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42060         LDKInitFeatures this_arg_conv;
42061         this_arg_conv.inner = (void*)(this_arg & (~1));
42062         this_arg_conv.is_owned = false;
42063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42064         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
42065 }
42066
42067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42068         LDKInitFeatures this_arg_conv;
42069         this_arg_conv.inner = (void*)(this_arg & (~1));
42070         this_arg_conv.is_owned = false;
42071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42072         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
42073 }
42074
42075 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42076         LDKInitFeatures this_arg_conv;
42077         this_arg_conv.inner = (void*)(this_arg & (~1));
42078         this_arg_conv.is_owned = false;
42079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42080         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
42081         return ret_conv;
42082 }
42083
42084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42085         LDKNodeFeatures this_arg_conv;
42086         this_arg_conv.inner = (void*)(this_arg & (~1));
42087         this_arg_conv.is_owned = false;
42088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42089         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
42090 }
42091
42092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42093         LDKNodeFeatures this_arg_conv;
42094         this_arg_conv.inner = (void*)(this_arg & (~1));
42095         this_arg_conv.is_owned = false;
42096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42097         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
42098 }
42099
42100 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42101         LDKNodeFeatures this_arg_conv;
42102         this_arg_conv.inner = (void*)(this_arg & (~1));
42103         this_arg_conv.is_owned = false;
42104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42105         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
42106         return ret_conv;
42107 }
42108
42109 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42110         LDKInitFeatures this_arg_conv;
42111         this_arg_conv.inner = (void*)(this_arg & (~1));
42112         this_arg_conv.is_owned = false;
42113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42114         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
42115         return ret_conv;
42116 }
42117
42118 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42119         LDKNodeFeatures this_arg_conv;
42120         this_arg_conv.inner = (void*)(this_arg & (~1));
42121         this_arg_conv.is_owned = false;
42122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42123         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
42124         return ret_conv;
42125 }
42126
42127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42128         LDKInitFeatures this_arg_conv;
42129         this_arg_conv.inner = (void*)(this_arg & (~1));
42130         this_arg_conv.is_owned = false;
42131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42132         InitFeatures_set_channel_type_optional(&this_arg_conv);
42133 }
42134
42135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42136         LDKInitFeatures this_arg_conv;
42137         this_arg_conv.inner = (void*)(this_arg & (~1));
42138         this_arg_conv.is_owned = false;
42139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42140         InitFeatures_set_channel_type_required(&this_arg_conv);
42141 }
42142
42143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42144         LDKInitFeatures this_arg_conv;
42145         this_arg_conv.inner = (void*)(this_arg & (~1));
42146         this_arg_conv.is_owned = false;
42147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42148         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
42149         return ret_conv;
42150 }
42151
42152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42153         LDKNodeFeatures this_arg_conv;
42154         this_arg_conv.inner = (void*)(this_arg & (~1));
42155         this_arg_conv.is_owned = false;
42156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42157         NodeFeatures_set_channel_type_optional(&this_arg_conv);
42158 }
42159
42160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42161         LDKNodeFeatures this_arg_conv;
42162         this_arg_conv.inner = (void*)(this_arg & (~1));
42163         this_arg_conv.is_owned = false;
42164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42165         NodeFeatures_set_channel_type_required(&this_arg_conv);
42166 }
42167
42168 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42169         LDKNodeFeatures this_arg_conv;
42170         this_arg_conv.inner = (void*)(this_arg & (~1));
42171         this_arg_conv.is_owned = false;
42172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42173         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
42174         return ret_conv;
42175 }
42176
42177 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42178         LDKInitFeatures this_arg_conv;
42179         this_arg_conv.inner = (void*)(this_arg & (~1));
42180         this_arg_conv.is_owned = false;
42181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42182         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
42183         return ret_conv;
42184 }
42185
42186 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42187         LDKNodeFeatures this_arg_conv;
42188         this_arg_conv.inner = (void*)(this_arg & (~1));
42189         this_arg_conv.is_owned = false;
42190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42191         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
42192         return ret_conv;
42193 }
42194
42195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42196         LDKInitFeatures this_arg_conv;
42197         this_arg_conv.inner = (void*)(this_arg & (~1));
42198         this_arg_conv.is_owned = false;
42199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42200         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
42201 }
42202
42203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42204         LDKInitFeatures this_arg_conv;
42205         this_arg_conv.inner = (void*)(this_arg & (~1));
42206         this_arg_conv.is_owned = false;
42207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42208         InitFeatures_set_scid_privacy_required(&this_arg_conv);
42209 }
42210
42211 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42212         LDKInitFeatures this_arg_conv;
42213         this_arg_conv.inner = (void*)(this_arg & (~1));
42214         this_arg_conv.is_owned = false;
42215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42216         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
42217         return ret_conv;
42218 }
42219
42220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42221         LDKNodeFeatures this_arg_conv;
42222         this_arg_conv.inner = (void*)(this_arg & (~1));
42223         this_arg_conv.is_owned = false;
42224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42225         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
42226 }
42227
42228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42229         LDKNodeFeatures this_arg_conv;
42230         this_arg_conv.inner = (void*)(this_arg & (~1));
42231         this_arg_conv.is_owned = false;
42232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42233         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
42234 }
42235
42236 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42237         LDKNodeFeatures this_arg_conv;
42238         this_arg_conv.inner = (void*)(this_arg & (~1));
42239         this_arg_conv.is_owned = false;
42240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42241         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
42242         return ret_conv;
42243 }
42244
42245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42246         LDKChannelTypeFeatures this_arg_conv;
42247         this_arg_conv.inner = (void*)(this_arg & (~1));
42248         this_arg_conv.is_owned = false;
42249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42250         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
42251 }
42252
42253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42254         LDKChannelTypeFeatures 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         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
42259 }
42260
42261 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42262         LDKChannelTypeFeatures 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         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
42267         return ret_conv;
42268 }
42269
42270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42271         LDKInitFeatures this_arg_conv;
42272         this_arg_conv.inner = (void*)(this_arg & (~1));
42273         this_arg_conv.is_owned = false;
42274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42275         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
42276         return ret_conv;
42277 }
42278
42279 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42280         LDKNodeFeatures this_arg_conv;
42281         this_arg_conv.inner = (void*)(this_arg & (~1));
42282         this_arg_conv.is_owned = false;
42283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42284         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
42285         return ret_conv;
42286 }
42287
42288 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42289         LDKChannelTypeFeatures this_arg_conv;
42290         this_arg_conv.inner = (void*)(this_arg & (~1));
42291         this_arg_conv.is_owned = false;
42292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42293         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
42294         return ret_conv;
42295 }
42296
42297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42298         LDKInitFeatures this_arg_conv;
42299         this_arg_conv.inner = (void*)(this_arg & (~1));
42300         this_arg_conv.is_owned = false;
42301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42302         InitFeatures_set_zero_conf_optional(&this_arg_conv);
42303 }
42304
42305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42306         LDKInitFeatures this_arg_conv;
42307         this_arg_conv.inner = (void*)(this_arg & (~1));
42308         this_arg_conv.is_owned = false;
42309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42310         InitFeatures_set_zero_conf_required(&this_arg_conv);
42311 }
42312
42313 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42314         LDKInitFeatures this_arg_conv;
42315         this_arg_conv.inner = (void*)(this_arg & (~1));
42316         this_arg_conv.is_owned = false;
42317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42318         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
42319         return ret_conv;
42320 }
42321
42322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42323         LDKNodeFeatures this_arg_conv;
42324         this_arg_conv.inner = (void*)(this_arg & (~1));
42325         this_arg_conv.is_owned = false;
42326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42327         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
42328 }
42329
42330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42331         LDKNodeFeatures this_arg_conv;
42332         this_arg_conv.inner = (void*)(this_arg & (~1));
42333         this_arg_conv.is_owned = false;
42334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42335         NodeFeatures_set_zero_conf_required(&this_arg_conv);
42336 }
42337
42338 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42339         LDKNodeFeatures this_arg_conv;
42340         this_arg_conv.inner = (void*)(this_arg & (~1));
42341         this_arg_conv.is_owned = false;
42342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42343         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
42344         return ret_conv;
42345 }
42346
42347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42348         LDKChannelTypeFeatures this_arg_conv;
42349         this_arg_conv.inner = (void*)(this_arg & (~1));
42350         this_arg_conv.is_owned = false;
42351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42352         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
42353 }
42354
42355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42356         LDKChannelTypeFeatures this_arg_conv;
42357         this_arg_conv.inner = (void*)(this_arg & (~1));
42358         this_arg_conv.is_owned = false;
42359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42360         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
42361 }
42362
42363 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42364         LDKChannelTypeFeatures this_arg_conv;
42365         this_arg_conv.inner = (void*)(this_arg & (~1));
42366         this_arg_conv.is_owned = false;
42367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42368         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
42369         return ret_conv;
42370 }
42371
42372 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42373         LDKInitFeatures this_arg_conv;
42374         this_arg_conv.inner = (void*)(this_arg & (~1));
42375         this_arg_conv.is_owned = false;
42376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42377         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
42378         return ret_conv;
42379 }
42380
42381 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42382         LDKNodeFeatures this_arg_conv;
42383         this_arg_conv.inner = (void*)(this_arg & (~1));
42384         this_arg_conv.is_owned = false;
42385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42386         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
42387         return ret_conv;
42388 }
42389
42390 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42391         LDKChannelTypeFeatures this_arg_conv;
42392         this_arg_conv.inner = (void*)(this_arg & (~1));
42393         this_arg_conv.is_owned = false;
42394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42395         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
42396         return ret_conv;
42397 }
42398
42399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42400         LDKNodeFeatures this_arg_conv;
42401         this_arg_conv.inner = (void*)(this_arg & (~1));
42402         this_arg_conv.is_owned = false;
42403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42404         NodeFeatures_set_keysend_optional(&this_arg_conv);
42405 }
42406
42407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42408         LDKNodeFeatures this_arg_conv;
42409         this_arg_conv.inner = (void*)(this_arg & (~1));
42410         this_arg_conv.is_owned = false;
42411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42412         NodeFeatures_set_keysend_required(&this_arg_conv);
42413 }
42414
42415 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
42416         LDKNodeFeatures this_arg_conv;
42417         this_arg_conv.inner = (void*)(this_arg & (~1));
42418         this_arg_conv.is_owned = false;
42419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42420         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
42421         return ret_conv;
42422 }
42423
42424 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
42425         LDKNodeFeatures this_arg_conv;
42426         this_arg_conv.inner = (void*)(this_arg & (~1));
42427         this_arg_conv.is_owned = false;
42428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42429         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
42430         return ret_conv;
42431 }
42432
42433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42434         LDKShutdownScript this_obj_conv;
42435         this_obj_conv.inner = (void*)(this_obj & (~1));
42436         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42438         ShutdownScript_free(this_obj_conv);
42439 }
42440
42441 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
42442         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
42443 int64_t ret_ref = 0;
42444 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42445 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42446 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42447 ret_ref = (uintptr_t)ret_var.inner;
42448 if (ret_var.is_owned) {
42449         ret_ref |= 1;
42450 }
42451         return ret_ref;
42452 }
42453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42454         LDKShutdownScript arg_conv;
42455         arg_conv.inner = (void*)(arg & (~1));
42456         arg_conv.is_owned = false;
42457         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42458         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
42459         return ret_conv;
42460 }
42461
42462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42463         LDKShutdownScript orig_conv;
42464         orig_conv.inner = (void*)(orig & (~1));
42465         orig_conv.is_owned = false;
42466         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42467         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
42468         int64_t ret_ref = 0;
42469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42472         ret_ref = (uintptr_t)ret_var.inner;
42473         if (ret_var.is_owned) {
42474                 ret_ref |= 1;
42475         }
42476         return ret_ref;
42477 }
42478
42479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42480         LDKInvalidShutdownScript this_obj_conv;
42481         this_obj_conv.inner = (void*)(this_obj & (~1));
42482         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42484         InvalidShutdownScript_free(this_obj_conv);
42485 }
42486
42487 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
42488         LDKInvalidShutdownScript this_ptr_conv;
42489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42490         this_ptr_conv.is_owned = false;
42491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42492         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
42493         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42494         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42495         return ret_arr;
42496 }
42497
42498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42499         LDKInvalidShutdownScript this_ptr_conv;
42500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42501         this_ptr_conv.is_owned = false;
42502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42503         LDKCVec_u8Z val_ref;
42504         val_ref.datalen = (*env)->GetArrayLength(env, val);
42505         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
42506         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
42507         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
42508 }
42509
42510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
42511         LDKCVec_u8Z script_arg_ref;
42512         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
42513         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
42514         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
42515         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
42516         int64_t ret_ref = 0;
42517         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42518         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42520         ret_ref = (uintptr_t)ret_var.inner;
42521         if (ret_var.is_owned) {
42522                 ret_ref |= 1;
42523         }
42524         return ret_ref;
42525 }
42526
42527 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
42528         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
42529 int64_t ret_ref = 0;
42530 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42531 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42532 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42533 ret_ref = (uintptr_t)ret_var.inner;
42534 if (ret_var.is_owned) {
42535         ret_ref |= 1;
42536 }
42537         return ret_ref;
42538 }
42539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42540         LDKInvalidShutdownScript arg_conv;
42541         arg_conv.inner = (void*)(arg & (~1));
42542         arg_conv.is_owned = false;
42543         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42544         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
42545         return ret_conv;
42546 }
42547
42548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42549         LDKInvalidShutdownScript orig_conv;
42550         orig_conv.inner = (void*)(orig & (~1));
42551         orig_conv.is_owned = false;
42552         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42553         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
42554         int64_t ret_ref = 0;
42555         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42556         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42558         ret_ref = (uintptr_t)ret_var.inner;
42559         if (ret_var.is_owned) {
42560                 ret_ref |= 1;
42561         }
42562         return ret_ref;
42563 }
42564
42565 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
42566         LDKShutdownScript obj_conv;
42567         obj_conv.inner = (void*)(obj & (~1));
42568         obj_conv.is_owned = false;
42569         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42570         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
42571         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42572         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42573         CVec_u8Z_free(ret_var);
42574         return ret_arr;
42575 }
42576
42577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42578         LDKu8slice ser_ref;
42579         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42580         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42581         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
42582         *ret_conv = ShutdownScript_read(ser_ref);
42583         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42584         return (int64_t)ret_conv;
42585 }
42586
42587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
42588         unsigned char pubkey_hash_arr[20];
42589         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
42590         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
42591         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
42592         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
42593         int64_t ret_ref = 0;
42594         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42595         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42596         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42597         ret_ref = (uintptr_t)ret_var.inner;
42598         if (ret_var.is_owned) {
42599                 ret_ref |= 1;
42600         }
42601         return ret_ref;
42602 }
42603
42604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
42605         unsigned char script_hash_arr[32];
42606         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
42607         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
42608         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
42609         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
42610         int64_t ret_ref = 0;
42611         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42612         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42614         ret_ref = (uintptr_t)ret_var.inner;
42615         if (ret_var.is_owned) {
42616                 ret_ref |= 1;
42617         }
42618         return ret_ref;
42619 }
42620
42621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
42622         
42623         LDKu8slice program_ref;
42624         program_ref.datalen = (*env)->GetArrayLength(env, program);
42625         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
42626         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
42627         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
42628         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
42629         return (int64_t)ret_conv;
42630 }
42631
42632 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
42633         LDKShutdownScript this_arg_conv;
42634         this_arg_conv.inner = (void*)(this_arg & (~1));
42635         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
42636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42637         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
42638         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
42639         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42640         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42641         CVec_u8Z_free(ret_var);
42642         return ret_arr;
42643 }
42644
42645 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
42646         LDKShutdownScript this_arg_conv;
42647         this_arg_conv.inner = (void*)(this_arg & (~1));
42648         this_arg_conv.is_owned = false;
42649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42650         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42651         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
42652         return ret_arr;
42653 }
42654
42655 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
42656         LDKShutdownScript this_arg_conv;
42657         this_arg_conv.inner = (void*)(this_arg & (~1));
42658         this_arg_conv.is_owned = false;
42659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42660         LDKInitFeatures features_conv;
42661         features_conv.inner = (void*)(features & (~1));
42662         features_conv.is_owned = false;
42663         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
42664         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
42665         return ret_conv;
42666 }
42667
42668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42669         if ((this_ptr & 1) != 0) return;
42670         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42671         CHECK_ACCESS(this_ptr_ptr);
42672         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
42673         FREE((void*)this_ptr);
42674         CustomMessageReader_free(this_ptr_conv);
42675 }
42676
42677 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
42678         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
42679         *ret_ret = Type_clone(arg);
42680         return (int64_t)ret_ret;
42681 }
42682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42683         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
42684         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
42685         LDKType* arg_conv = (LDKType*)arg_ptr;
42686         int64_t ret_conv = Type_clone_ptr(arg_conv);
42687         return ret_conv;
42688 }
42689
42690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42691         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
42692         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
42693         LDKType* orig_conv = (LDKType*)orig_ptr;
42694         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
42695         *ret_ret = Type_clone(orig_conv);
42696         return (int64_t)ret_ret;
42697 }
42698
42699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42700         if ((this_ptr & 1) != 0) return;
42701         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42702         CHECK_ACCESS(this_ptr_ptr);
42703         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
42704         FREE((void*)this_ptr);
42705         Type_free(this_ptr_conv);
42706 }
42707
42708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42709         LDKNodeId this_obj_conv;
42710         this_obj_conv.inner = (void*)(this_obj & (~1));
42711         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42713         NodeId_free(this_obj_conv);
42714 }
42715
42716 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
42717         LDKNodeId ret_var = NodeId_clone(arg);
42718 int64_t ret_ref = 0;
42719 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42720 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42721 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42722 ret_ref = (uintptr_t)ret_var.inner;
42723 if (ret_var.is_owned) {
42724         ret_ref |= 1;
42725 }
42726         return ret_ref;
42727 }
42728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42729         LDKNodeId arg_conv;
42730         arg_conv.inner = (void*)(arg & (~1));
42731         arg_conv.is_owned = false;
42732         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42733         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
42734         return ret_conv;
42735 }
42736
42737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42738         LDKNodeId orig_conv;
42739         orig_conv.inner = (void*)(orig & (~1));
42740         orig_conv.is_owned = false;
42741         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42742         LDKNodeId ret_var = NodeId_clone(&orig_conv);
42743         int64_t ret_ref = 0;
42744         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42745         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42747         ret_ref = (uintptr_t)ret_var.inner;
42748         if (ret_var.is_owned) {
42749                 ret_ref |= 1;
42750         }
42751         return ret_ref;
42752 }
42753
42754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
42755         LDKPublicKey pubkey_ref;
42756         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
42757         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
42758         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
42759         int64_t ret_ref = 0;
42760         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42761         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42763         ret_ref = (uintptr_t)ret_var.inner;
42764         if (ret_var.is_owned) {
42765                 ret_ref |= 1;
42766         }
42767         return ret_ref;
42768 }
42769
42770 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
42771         LDKNodeId this_arg_conv;
42772         this_arg_conv.inner = (void*)(this_arg & (~1));
42773         this_arg_conv.is_owned = false;
42774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42775         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
42776         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42777         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42778         return ret_arr;
42779 }
42780
42781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
42782         LDKNodeId o_conv;
42783         o_conv.inner = (void*)(o & (~1));
42784         o_conv.is_owned = false;
42785         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42786         int64_t ret_conv = NodeId_hash(&o_conv);
42787         return ret_conv;
42788 }
42789
42790 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
42791         LDKNodeId obj_conv;
42792         obj_conv.inner = (void*)(obj & (~1));
42793         obj_conv.is_owned = false;
42794         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42795         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
42796         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42797         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42798         CVec_u8Z_free(ret_var);
42799         return ret_arr;
42800 }
42801
42802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42803         LDKu8slice ser_ref;
42804         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42805         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42806         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
42807         *ret_conv = NodeId_read(ser_ref);
42808         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42809         return (int64_t)ret_conv;
42810 }
42811
42812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42813         LDKNetworkGraph this_obj_conv;
42814         this_obj_conv.inner = (void*)(this_obj & (~1));
42815         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42817         NetworkGraph_free(this_obj_conv);
42818 }
42819
42820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42821         LDKReadOnlyNetworkGraph this_obj_conv;
42822         this_obj_conv.inner = (void*)(this_obj & (~1));
42823         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42825         ReadOnlyNetworkGraph_free(this_obj_conv);
42826 }
42827
42828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42829         if ((this_ptr & 1) != 0) return;
42830         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42831         CHECK_ACCESS(this_ptr_ptr);
42832         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
42833         FREE((void*)this_ptr);
42834         NetworkUpdate_free(this_ptr_conv);
42835 }
42836
42837 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
42838         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42839         *ret_copy = NetworkUpdate_clone(arg);
42840 int64_t ret_ref = (uintptr_t)ret_copy;
42841         return ret_ref;
42842 }
42843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42844         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
42845         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
42846         return ret_conv;
42847 }
42848
42849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42850         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
42851         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42852         *ret_copy = NetworkUpdate_clone(orig_conv);
42853         int64_t ret_ref = (uintptr_t)ret_copy;
42854         return ret_ref;
42855 }
42856
42857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
42858         LDKChannelUpdate msg_conv;
42859         msg_conv.inner = (void*)(msg & (~1));
42860         msg_conv.is_owned = (msg & 1) || (msg == 0);
42861         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
42862         msg_conv = ChannelUpdate_clone(&msg_conv);
42863         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42864         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
42865         int64_t ret_ref = (uintptr_t)ret_copy;
42866         return ret_ref;
42867 }
42868
42869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1failure(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
42870         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42871         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
42872         int64_t ret_ref = (uintptr_t)ret_copy;
42873         return ret_ref;
42874 }
42875
42876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
42877         LDKPublicKey node_id_ref;
42878         CHECK((*env)->GetArrayLength(env, node_id) == 33);
42879         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
42880         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42881         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
42882         int64_t ret_ref = (uintptr_t)ret_copy;
42883         return ret_ref;
42884 }
42885
42886 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
42887         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
42888         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
42889         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42890         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42891         CVec_u8Z_free(ret_var);
42892         return ret_arr;
42893 }
42894
42895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42896         LDKu8slice ser_ref;
42897         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42898         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42899         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
42900         *ret_conv = NetworkUpdate_read(ser_ref);
42901         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42902         return (int64_t)ret_conv;
42903 }
42904
42905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42906         LDKP2PGossipSync this_obj_conv;
42907         this_obj_conv.inner = (void*)(this_obj & (~1));
42908         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42910         P2PGossipSync_free(this_obj_conv);
42911 }
42912
42913 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) {
42914         LDKNetworkGraph network_graph_conv;
42915         network_graph_conv.inner = (void*)(network_graph & (~1));
42916         network_graph_conv.is_owned = false;
42917         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42918         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
42919         CHECK_ACCESS(chain_access_ptr);
42920         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
42921         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
42922         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
42923                 // Manually implement clone for Java trait instances
42924                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
42925                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42926                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
42927                 }
42928         }
42929         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42930         CHECK_ACCESS(logger_ptr);
42931         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42932         if (logger_conv.free == LDKLogger_JCalls_free) {
42933                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42934                 LDKLogger_JCalls_cloned(&logger_conv);
42935         }
42936         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
42937         int64_t ret_ref = 0;
42938         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42939         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42941         ret_ref = (uintptr_t)ret_var.inner;
42942         if (ret_var.is_owned) {
42943                 ret_ref |= 1;
42944         }
42945         return ret_ref;
42946 }
42947
42948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
42949         LDKP2PGossipSync this_arg_conv;
42950         this_arg_conv.inner = (void*)(this_arg & (~1));
42951         this_arg_conv.is_owned = false;
42952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42953         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
42954         CHECK_ACCESS(chain_access_ptr);
42955         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
42956         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
42957         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
42958                 // Manually implement clone for Java trait instances
42959                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
42960                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42961                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
42962                 }
42963         }
42964         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
42965 }
42966
42967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
42968         LDKNetworkGraph this_arg_conv;
42969         this_arg_conv.inner = (void*)(this_arg & (~1));
42970         this_arg_conv.is_owned = false;
42971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42972         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
42973         *ret_ret = NetworkGraph_as_EventHandler(&this_arg_conv);
42974         return (int64_t)ret_ret;
42975 }
42976
42977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
42978         LDKP2PGossipSync this_arg_conv;
42979         this_arg_conv.inner = (void*)(this_arg & (~1));
42980         this_arg_conv.is_owned = false;
42981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42982         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
42983         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
42984         return (int64_t)ret_ret;
42985 }
42986
42987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
42988         LDKP2PGossipSync this_arg_conv;
42989         this_arg_conv.inner = (void*)(this_arg & (~1));
42990         this_arg_conv.is_owned = false;
42991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42992         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
42993         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
42994         return (int64_t)ret_ret;
42995 }
42996
42997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42998         LDKChannelUpdateInfo this_obj_conv;
42999         this_obj_conv.inner = (void*)(this_obj & (~1));
43000         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43002         ChannelUpdateInfo_free(this_obj_conv);
43003 }
43004
43005 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
43006         LDKChannelUpdateInfo this_ptr_conv;
43007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43008         this_ptr_conv.is_owned = false;
43009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43010         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
43011         return ret_conv;
43012 }
43013
43014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43015         LDKChannelUpdateInfo this_ptr_conv;
43016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43017         this_ptr_conv.is_owned = false;
43018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43019         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
43020 }
43021
43022 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
43023         LDKChannelUpdateInfo this_ptr_conv;
43024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43025         this_ptr_conv.is_owned = false;
43026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43027         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
43028         return ret_conv;
43029 }
43030
43031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
43032         LDKChannelUpdateInfo this_ptr_conv;
43033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43034         this_ptr_conv.is_owned = false;
43035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43036         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
43037 }
43038
43039 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
43040         LDKChannelUpdateInfo this_ptr_conv;
43041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43042         this_ptr_conv.is_owned = false;
43043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43044         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
43045         return ret_conv;
43046 }
43047
43048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
43049         LDKChannelUpdateInfo this_ptr_conv;
43050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43051         this_ptr_conv.is_owned = false;
43052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43053         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
43054 }
43055
43056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43057         LDKChannelUpdateInfo this_ptr_conv;
43058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43059         this_ptr_conv.is_owned = false;
43060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43061         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
43062         return ret_conv;
43063 }
43064
43065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43066         LDKChannelUpdateInfo this_ptr_conv;
43067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43068         this_ptr_conv.is_owned = false;
43069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43070         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
43071 }
43072
43073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43074         LDKChannelUpdateInfo this_ptr_conv;
43075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43076         this_ptr_conv.is_owned = false;
43077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43078         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
43079         return ret_conv;
43080 }
43081
43082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43083         LDKChannelUpdateInfo this_ptr_conv;
43084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43085         this_ptr_conv.is_owned = false;
43086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43087         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
43088 }
43089
43090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
43091         LDKChannelUpdateInfo this_ptr_conv;
43092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43093         this_ptr_conv.is_owned = false;
43094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43095         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
43096         int64_t ret_ref = 0;
43097         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43098         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43100         ret_ref = (uintptr_t)ret_var.inner;
43101         if (ret_var.is_owned) {
43102                 ret_ref |= 1;
43103         }
43104         return ret_ref;
43105 }
43106
43107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43108         LDKChannelUpdateInfo this_ptr_conv;
43109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43110         this_ptr_conv.is_owned = false;
43111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43112         LDKRoutingFees val_conv;
43113         val_conv.inner = (void*)(val & (~1));
43114         val_conv.is_owned = (val & 1) || (val == 0);
43115         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43116         val_conv = RoutingFees_clone(&val_conv);
43117         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
43118 }
43119
43120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
43121         LDKChannelUpdateInfo this_ptr_conv;
43122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43123         this_ptr_conv.is_owned = false;
43124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43125         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
43126         int64_t ret_ref = 0;
43127         if ((uintptr_t)ret_var.inner > 4096) {
43128                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43129                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43131                 ret_ref = (uintptr_t)ret_var.inner;
43132                 if (ret_var.is_owned) {
43133                         ret_ref |= 1;
43134                 }
43135         }
43136         return ret_ref;
43137 }
43138
43139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43140         LDKChannelUpdateInfo this_ptr_conv;
43141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43142         this_ptr_conv.is_owned = false;
43143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43144         LDKChannelUpdate val_conv;
43145         val_conv.inner = (void*)(val & (~1));
43146         val_conv.is_owned = (val & 1) || (val == 0);
43147         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43148         val_conv = ChannelUpdate_clone(&val_conv);
43149         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
43150 }
43151
43152 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) {
43153         LDKRoutingFees fees_arg_conv;
43154         fees_arg_conv.inner = (void*)(fees_arg & (~1));
43155         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
43156         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
43157         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
43158         LDKChannelUpdate last_update_message_arg_conv;
43159         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
43160         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
43161         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
43162         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
43163         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);
43164         int64_t ret_ref = 0;
43165         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43166         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43168         ret_ref = (uintptr_t)ret_var.inner;
43169         if (ret_var.is_owned) {
43170                 ret_ref |= 1;
43171         }
43172         return ret_ref;
43173 }
43174
43175 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
43176         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
43177 int64_t ret_ref = 0;
43178 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43179 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43180 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43181 ret_ref = (uintptr_t)ret_var.inner;
43182 if (ret_var.is_owned) {
43183         ret_ref |= 1;
43184 }
43185         return ret_ref;
43186 }
43187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43188         LDKChannelUpdateInfo arg_conv;
43189         arg_conv.inner = (void*)(arg & (~1));
43190         arg_conv.is_owned = false;
43191         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43192         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
43193         return ret_conv;
43194 }
43195
43196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43197         LDKChannelUpdateInfo orig_conv;
43198         orig_conv.inner = (void*)(orig & (~1));
43199         orig_conv.is_owned = false;
43200         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43201         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
43202         int64_t ret_ref = 0;
43203         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43204         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43206         ret_ref = (uintptr_t)ret_var.inner;
43207         if (ret_var.is_owned) {
43208                 ret_ref |= 1;
43209         }
43210         return ret_ref;
43211 }
43212
43213 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
43214         LDKChannelUpdateInfo obj_conv;
43215         obj_conv.inner = (void*)(obj & (~1));
43216         obj_conv.is_owned = false;
43217         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43218         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
43219         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43220         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43221         CVec_u8Z_free(ret_var);
43222         return ret_arr;
43223 }
43224
43225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43226         LDKu8slice ser_ref;
43227         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43228         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43229         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
43230         *ret_conv = ChannelUpdateInfo_read(ser_ref);
43231         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43232         return (int64_t)ret_conv;
43233 }
43234
43235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43236         LDKChannelInfo this_obj_conv;
43237         this_obj_conv.inner = (void*)(this_obj & (~1));
43238         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43240         ChannelInfo_free(this_obj_conv);
43241 }
43242
43243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
43244         LDKChannelInfo this_ptr_conv;
43245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43246         this_ptr_conv.is_owned = false;
43247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43248         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
43249         int64_t ret_ref = 0;
43250         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43251         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43253         ret_ref = (uintptr_t)ret_var.inner;
43254         if (ret_var.is_owned) {
43255                 ret_ref |= 1;
43256         }
43257         return ret_ref;
43258 }
43259
43260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43261         LDKChannelInfo this_ptr_conv;
43262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43263         this_ptr_conv.is_owned = false;
43264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43265         LDKChannelFeatures val_conv;
43266         val_conv.inner = (void*)(val & (~1));
43267         val_conv.is_owned = (val & 1) || (val == 0);
43268         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43269         val_conv = ChannelFeatures_clone(&val_conv);
43270         ChannelInfo_set_features(&this_ptr_conv, val_conv);
43271 }
43272
43273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
43274         LDKChannelInfo this_ptr_conv;
43275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43276         this_ptr_conv.is_owned = false;
43277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43278         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
43279         int64_t ret_ref = 0;
43280         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43281         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43283         ret_ref = (uintptr_t)ret_var.inner;
43284         if (ret_var.is_owned) {
43285                 ret_ref |= 1;
43286         }
43287         return ret_ref;
43288 }
43289
43290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43291         LDKChannelInfo this_ptr_conv;
43292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43293         this_ptr_conv.is_owned = false;
43294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43295         LDKNodeId val_conv;
43296         val_conv.inner = (void*)(val & (~1));
43297         val_conv.is_owned = (val & 1) || (val == 0);
43298         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43299         val_conv = NodeId_clone(&val_conv);
43300         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
43301 }
43302
43303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
43304         LDKChannelInfo this_ptr_conv;
43305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43306         this_ptr_conv.is_owned = false;
43307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43308         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
43309         int64_t ret_ref = 0;
43310         if ((uintptr_t)ret_var.inner > 4096) {
43311                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43312                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43314                 ret_ref = (uintptr_t)ret_var.inner;
43315                 if (ret_var.is_owned) {
43316                         ret_ref |= 1;
43317                 }
43318         }
43319         return ret_ref;
43320 }
43321
43322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43323         LDKChannelInfo this_ptr_conv;
43324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43325         this_ptr_conv.is_owned = false;
43326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43327         LDKChannelUpdateInfo val_conv;
43328         val_conv.inner = (void*)(val & (~1));
43329         val_conv.is_owned = (val & 1) || (val == 0);
43330         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43331         val_conv = ChannelUpdateInfo_clone(&val_conv);
43332         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
43333 }
43334
43335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
43336         LDKChannelInfo this_ptr_conv;
43337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43338         this_ptr_conv.is_owned = false;
43339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43340         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
43341         int64_t ret_ref = 0;
43342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43345         ret_ref = (uintptr_t)ret_var.inner;
43346         if (ret_var.is_owned) {
43347                 ret_ref |= 1;
43348         }
43349         return ret_ref;
43350 }
43351
43352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43353         LDKChannelInfo this_ptr_conv;
43354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43355         this_ptr_conv.is_owned = false;
43356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43357         LDKNodeId val_conv;
43358         val_conv.inner = (void*)(val & (~1));
43359         val_conv.is_owned = (val & 1) || (val == 0);
43360         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43361         val_conv = NodeId_clone(&val_conv);
43362         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
43363 }
43364
43365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
43366         LDKChannelInfo this_ptr_conv;
43367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43368         this_ptr_conv.is_owned = false;
43369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43370         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
43371         int64_t ret_ref = 0;
43372         if ((uintptr_t)ret_var.inner > 4096) {
43373                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43374                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43375         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43376                 ret_ref = (uintptr_t)ret_var.inner;
43377                 if (ret_var.is_owned) {
43378                         ret_ref |= 1;
43379                 }
43380         }
43381         return ret_ref;
43382 }
43383
43384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43385         LDKChannelInfo this_ptr_conv;
43386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43387         this_ptr_conv.is_owned = false;
43388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43389         LDKChannelUpdateInfo val_conv;
43390         val_conv.inner = (void*)(val & (~1));
43391         val_conv.is_owned = (val & 1) || (val == 0);
43392         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43393         val_conv = ChannelUpdateInfo_clone(&val_conv);
43394         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
43395 }
43396
43397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
43398         LDKChannelInfo this_ptr_conv;
43399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43400         this_ptr_conv.is_owned = false;
43401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43402         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
43403         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
43404         int64_t ret_ref = (uintptr_t)ret_copy;
43405         return ret_ref;
43406 }
43407
43408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43409         LDKChannelInfo this_ptr_conv;
43410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43411         this_ptr_conv.is_owned = false;
43412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43413         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
43414         CHECK_ACCESS(val_ptr);
43415         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
43416         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
43417         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
43418 }
43419
43420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
43421         LDKChannelInfo this_ptr_conv;
43422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43423         this_ptr_conv.is_owned = false;
43424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43425         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
43426         int64_t ret_ref = 0;
43427         if ((uintptr_t)ret_var.inner > 4096) {
43428                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43429                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43431                 ret_ref = (uintptr_t)ret_var.inner;
43432                 if (ret_var.is_owned) {
43433                         ret_ref |= 1;
43434                 }
43435         }
43436         return ret_ref;
43437 }
43438
43439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43440         LDKChannelInfo this_ptr_conv;
43441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43442         this_ptr_conv.is_owned = false;
43443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43444         LDKChannelAnnouncement val_conv;
43445         val_conv.inner = (void*)(val & (~1));
43446         val_conv.is_owned = (val & 1) || (val == 0);
43447         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43448         val_conv = ChannelAnnouncement_clone(&val_conv);
43449         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
43450 }
43451
43452 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
43453         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
43454 int64_t ret_ref = 0;
43455 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43456 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43457 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43458 ret_ref = (uintptr_t)ret_var.inner;
43459 if (ret_var.is_owned) {
43460         ret_ref |= 1;
43461 }
43462         return ret_ref;
43463 }
43464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43465         LDKChannelInfo arg_conv;
43466         arg_conv.inner = (void*)(arg & (~1));
43467         arg_conv.is_owned = false;
43468         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43469         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
43470         return ret_conv;
43471 }
43472
43473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43474         LDKChannelInfo orig_conv;
43475         orig_conv.inner = (void*)(orig & (~1));
43476         orig_conv.is_owned = false;
43477         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43478         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
43479         int64_t ret_ref = 0;
43480         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43481         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43483         ret_ref = (uintptr_t)ret_var.inner;
43484         if (ret_var.is_owned) {
43485                 ret_ref |= 1;
43486         }
43487         return ret_ref;
43488 }
43489
43490 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) {
43491         LDKChannelInfo this_arg_conv;
43492         this_arg_conv.inner = (void*)(this_arg & (~1));
43493         this_arg_conv.is_owned = false;
43494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43495         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
43496         int64_t ret_ref = 0;
43497         if ((uintptr_t)ret_var.inner > 4096) {
43498                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43499                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43501                 ret_ref = (uintptr_t)ret_var.inner;
43502                 if (ret_var.is_owned) {
43503                         ret_ref |= 1;
43504                 }
43505         }
43506         return ret_ref;
43507 }
43508
43509 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
43510         LDKChannelInfo obj_conv;
43511         obj_conv.inner = (void*)(obj & (~1));
43512         obj_conv.is_owned = false;
43513         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43514         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
43515         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43516         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43517         CVec_u8Z_free(ret_var);
43518         return ret_arr;
43519 }
43520
43521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43522         LDKu8slice ser_ref;
43523         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43524         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43525         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
43526         *ret_conv = ChannelInfo_read(ser_ref);
43527         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43528         return (int64_t)ret_conv;
43529 }
43530
43531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43532         LDKDirectedChannelInfo this_obj_conv;
43533         this_obj_conv.inner = (void*)(this_obj & (~1));
43534         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43536         DirectedChannelInfo_free(this_obj_conv);
43537 }
43538
43539 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
43540         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
43541 int64_t ret_ref = 0;
43542 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43543 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43544 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43545 ret_ref = (uintptr_t)ret_var.inner;
43546 if (ret_var.is_owned) {
43547         ret_ref |= 1;
43548 }
43549         return ret_ref;
43550 }
43551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43552         LDKDirectedChannelInfo arg_conv;
43553         arg_conv.inner = (void*)(arg & (~1));
43554         arg_conv.is_owned = false;
43555         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43556         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
43557         return ret_conv;
43558 }
43559
43560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43561         LDKDirectedChannelInfo orig_conv;
43562         orig_conv.inner = (void*)(orig & (~1));
43563         orig_conv.is_owned = false;
43564         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43565         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
43566         int64_t ret_ref = 0;
43567         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43568         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43570         ret_ref = (uintptr_t)ret_var.inner;
43571         if (ret_var.is_owned) {
43572                 ret_ref |= 1;
43573         }
43574         return ret_ref;
43575 }
43576
43577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
43578         LDKDirectedChannelInfo this_arg_conv;
43579         this_arg_conv.inner = (void*)(this_arg & (~1));
43580         this_arg_conv.is_owned = false;
43581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43582         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
43583         int64_t ret_ref = 0;
43584         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43585         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43587         ret_ref = (uintptr_t)ret_var.inner;
43588         if (ret_var.is_owned) {
43589                 ret_ref |= 1;
43590         }
43591         return ret_ref;
43592 }
43593
43594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1direction(JNIEnv *env, jclass clz, int64_t this_arg) {
43595         LDKDirectedChannelInfo this_arg_conv;
43596         this_arg_conv.inner = (void*)(this_arg & (~1));
43597         this_arg_conv.is_owned = false;
43598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43599         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
43600         int64_t ret_ref = 0;
43601         if ((uintptr_t)ret_var.inner > 4096) {
43602                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43603                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43605                 ret_ref = (uintptr_t)ret_var.inner;
43606                 if (ret_var.is_owned) {
43607                         ret_ref |= 1;
43608                 }
43609         }
43610         return ret_ref;
43611 }
43612
43613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
43614         LDKDirectedChannelInfo this_arg_conv;
43615         this_arg_conv.inner = (void*)(this_arg & (~1));
43616         this_arg_conv.is_owned = false;
43617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43618         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
43619         return ret_conv;
43620 }
43621
43622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
43623         LDKDirectedChannelInfo this_arg_conv;
43624         this_arg_conv.inner = (void*)(this_arg & (~1));
43625         this_arg_conv.is_owned = false;
43626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43627         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43628         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
43629         int64_t ret_ref = (uintptr_t)ret_copy;
43630         return ret_ref;
43631 }
43632
43633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
43634         if ((this_ptr & 1) != 0) return;
43635         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43636         CHECK_ACCESS(this_ptr_ptr);
43637         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
43638         FREE((void*)this_ptr);
43639         EffectiveCapacity_free(this_ptr_conv);
43640 }
43641
43642 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
43643         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43644         *ret_copy = EffectiveCapacity_clone(arg);
43645 int64_t ret_ref = (uintptr_t)ret_copy;
43646         return ret_ref;
43647 }
43648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43649         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
43650         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
43651         return ret_conv;
43652 }
43653
43654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43655         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
43656         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43657         *ret_copy = EffectiveCapacity_clone(orig_conv);
43658         int64_t ret_ref = (uintptr_t)ret_copy;
43659         return ret_ref;
43660 }
43661
43662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
43663         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43664         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
43665         int64_t ret_ref = (uintptr_t)ret_copy;
43666         return ret_ref;
43667 }
43668
43669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
43670         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43671         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
43672         int64_t ret_ref = (uintptr_t)ret_copy;
43673         return ret_ref;
43674 }
43675
43676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat, int64_t htlc_maximum_msat) {
43677         void* htlc_maximum_msat_ptr = (void*)(((uintptr_t)htlc_maximum_msat) & ~1);
43678         CHECK_ACCESS(htlc_maximum_msat_ptr);
43679         LDKCOption_u64Z htlc_maximum_msat_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_ptr);
43680         htlc_maximum_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat) & ~1));
43681         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43682         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat_conv);
43683         int64_t ret_ref = (uintptr_t)ret_copy;
43684         return ret_ref;
43685 }
43686
43687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
43688         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43689         *ret_copy = EffectiveCapacity_infinite();
43690         int64_t ret_ref = (uintptr_t)ret_copy;
43691         return ret_ref;
43692 }
43693
43694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
43695         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43696         *ret_copy = EffectiveCapacity_unknown();
43697         int64_t ret_ref = (uintptr_t)ret_copy;
43698         return ret_ref;
43699 }
43700
43701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
43702         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
43703         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
43704         return ret_conv;
43705 }
43706
43707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43708         LDKRoutingFees this_obj_conv;
43709         this_obj_conv.inner = (void*)(this_obj & (~1));
43710         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43712         RoutingFees_free(this_obj_conv);
43713 }
43714
43715 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43716         LDKRoutingFees this_ptr_conv;
43717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43718         this_ptr_conv.is_owned = false;
43719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43720         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
43721         return ret_conv;
43722 }
43723
43724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43725         LDKRoutingFees this_ptr_conv;
43726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43727         this_ptr_conv.is_owned = false;
43728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43729         RoutingFees_set_base_msat(&this_ptr_conv, val);
43730 }
43731
43732 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
43733         LDKRoutingFees this_ptr_conv;
43734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43735         this_ptr_conv.is_owned = false;
43736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43737         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
43738         return ret_conv;
43739 }
43740
43741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43742         LDKRoutingFees this_ptr_conv;
43743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43744         this_ptr_conv.is_owned = false;
43745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43746         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
43747 }
43748
43749 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) {
43750         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
43751         int64_t ret_ref = 0;
43752         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43753         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43755         ret_ref = (uintptr_t)ret_var.inner;
43756         if (ret_var.is_owned) {
43757                 ret_ref |= 1;
43758         }
43759         return ret_ref;
43760 }
43761
43762 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43763         LDKRoutingFees a_conv;
43764         a_conv.inner = (void*)(a & (~1));
43765         a_conv.is_owned = false;
43766         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43767         LDKRoutingFees b_conv;
43768         b_conv.inner = (void*)(b & (~1));
43769         b_conv.is_owned = false;
43770         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43771         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
43772         return ret_conv;
43773 }
43774
43775 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
43776         LDKRoutingFees ret_var = RoutingFees_clone(arg);
43777 int64_t ret_ref = 0;
43778 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43779 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43780 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43781 ret_ref = (uintptr_t)ret_var.inner;
43782 if (ret_var.is_owned) {
43783         ret_ref |= 1;
43784 }
43785         return ret_ref;
43786 }
43787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43788         LDKRoutingFees arg_conv;
43789         arg_conv.inner = (void*)(arg & (~1));
43790         arg_conv.is_owned = false;
43791         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43792         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
43793         return ret_conv;
43794 }
43795
43796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43797         LDKRoutingFees orig_conv;
43798         orig_conv.inner = (void*)(orig & (~1));
43799         orig_conv.is_owned = false;
43800         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43801         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
43802         int64_t ret_ref = 0;
43803         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43804         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43806         ret_ref = (uintptr_t)ret_var.inner;
43807         if (ret_var.is_owned) {
43808                 ret_ref |= 1;
43809         }
43810         return ret_ref;
43811 }
43812
43813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
43814         LDKRoutingFees o_conv;
43815         o_conv.inner = (void*)(o & (~1));
43816         o_conv.is_owned = false;
43817         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43818         int64_t ret_conv = RoutingFees_hash(&o_conv);
43819         return ret_conv;
43820 }
43821
43822 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
43823         LDKRoutingFees obj_conv;
43824         obj_conv.inner = (void*)(obj & (~1));
43825         obj_conv.is_owned = false;
43826         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43827         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
43828         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43829         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43830         CVec_u8Z_free(ret_var);
43831         return ret_arr;
43832 }
43833
43834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43835         LDKu8slice ser_ref;
43836         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43837         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43838         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
43839         *ret_conv = RoutingFees_read(ser_ref);
43840         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43841         return (int64_t)ret_conv;
43842 }
43843
43844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43845         LDKNodeAnnouncementInfo this_obj_conv;
43846         this_obj_conv.inner = (void*)(this_obj & (~1));
43847         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43849         NodeAnnouncementInfo_free(this_obj_conv);
43850 }
43851
43852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
43853         LDKNodeAnnouncementInfo this_ptr_conv;
43854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43855         this_ptr_conv.is_owned = false;
43856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43857         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
43858         int64_t ret_ref = 0;
43859         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43860         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43862         ret_ref = (uintptr_t)ret_var.inner;
43863         if (ret_var.is_owned) {
43864                 ret_ref |= 1;
43865         }
43866         return ret_ref;
43867 }
43868
43869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43870         LDKNodeAnnouncementInfo this_ptr_conv;
43871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43872         this_ptr_conv.is_owned = false;
43873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43874         LDKNodeFeatures val_conv;
43875         val_conv.inner = (void*)(val & (~1));
43876         val_conv.is_owned = (val & 1) || (val == 0);
43877         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43878         val_conv = NodeFeatures_clone(&val_conv);
43879         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
43880 }
43881
43882 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
43883         LDKNodeAnnouncementInfo this_ptr_conv;
43884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43885         this_ptr_conv.is_owned = false;
43886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43887         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
43888         return ret_conv;
43889 }
43890
43891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43892         LDKNodeAnnouncementInfo this_ptr_conv;
43893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43894         this_ptr_conv.is_owned = false;
43895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43896         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
43897 }
43898
43899 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
43900         LDKNodeAnnouncementInfo this_ptr_conv;
43901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43902         this_ptr_conv.is_owned = false;
43903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43904         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
43905         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
43906         return ret_arr;
43907 }
43908
43909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43910         LDKNodeAnnouncementInfo this_ptr_conv;
43911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43912         this_ptr_conv.is_owned = false;
43913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43914         LDKThreeBytes val_ref;
43915         CHECK((*env)->GetArrayLength(env, val) == 3);
43916         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
43917         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
43918 }
43919
43920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
43921         LDKNodeAnnouncementInfo this_ptr_conv;
43922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43923         this_ptr_conv.is_owned = false;
43924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43925         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
43926         int64_t ret_ref = 0;
43927         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43928         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43930         ret_ref = (uintptr_t)ret_var.inner;
43931         if (ret_var.is_owned) {
43932                 ret_ref |= 1;
43933         }
43934         return ret_ref;
43935 }
43936
43937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43938         LDKNodeAnnouncementInfo this_ptr_conv;
43939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43940         this_ptr_conv.is_owned = false;
43941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43942         LDKNodeAlias val_conv;
43943         val_conv.inner = (void*)(val & (~1));
43944         val_conv.is_owned = (val & 1) || (val == 0);
43945         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43946         val_conv = NodeAlias_clone(&val_conv);
43947         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
43948 }
43949
43950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
43951         LDKNodeAnnouncementInfo this_ptr_conv;
43952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43953         this_ptr_conv.is_owned = false;
43954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43955         LDKCVec_NetAddressZ val_constr;
43956         val_constr.datalen = (*env)->GetArrayLength(env, val);
43957         if (val_constr.datalen > 0)
43958                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
43959         else
43960                 val_constr.data = NULL;
43961         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
43962         for (size_t m = 0; m < val_constr.datalen; m++) {
43963                 int64_t val_conv_12 = val_vals[m];
43964                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
43965                 CHECK_ACCESS(val_conv_12_ptr);
43966                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
43967                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
43968                 val_constr.data[m] = val_conv_12_conv;
43969         }
43970         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
43971         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
43972 }
43973
43974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
43975         LDKNodeAnnouncementInfo this_ptr_conv;
43976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43977         this_ptr_conv.is_owned = false;
43978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43979         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
43980         int64_t ret_ref = 0;
43981         if ((uintptr_t)ret_var.inner > 4096) {
43982                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43983                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43985                 ret_ref = (uintptr_t)ret_var.inner;
43986                 if (ret_var.is_owned) {
43987                         ret_ref |= 1;
43988                 }
43989         }
43990         return ret_ref;
43991 }
43992
43993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43994         LDKNodeAnnouncementInfo this_ptr_conv;
43995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43996         this_ptr_conv.is_owned = false;
43997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43998         LDKNodeAnnouncement val_conv;
43999         val_conv.inner = (void*)(val & (~1));
44000         val_conv.is_owned = (val & 1) || (val == 0);
44001         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44002         val_conv = NodeAnnouncement_clone(&val_conv);
44003         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
44004 }
44005
44006 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) {
44007         LDKNodeFeatures features_arg_conv;
44008         features_arg_conv.inner = (void*)(features_arg & (~1));
44009         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
44010         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
44011         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
44012         LDKThreeBytes rgb_arg_ref;
44013         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
44014         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
44015         LDKNodeAlias alias_arg_conv;
44016         alias_arg_conv.inner = (void*)(alias_arg & (~1));
44017         alias_arg_conv.is_owned = (alias_arg & 1) || (alias_arg == 0);
44018         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
44019         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
44020         LDKCVec_NetAddressZ addresses_arg_constr;
44021         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
44022         if (addresses_arg_constr.datalen > 0)
44023                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
44024         else
44025                 addresses_arg_constr.data = NULL;
44026         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
44027         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
44028                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
44029                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
44030                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
44031                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
44032                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
44033         }
44034         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
44035         LDKNodeAnnouncement announcement_message_arg_conv;
44036         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
44037         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
44038         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
44039         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
44040         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
44041         int64_t ret_ref = 0;
44042         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44043         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44045         ret_ref = (uintptr_t)ret_var.inner;
44046         if (ret_var.is_owned) {
44047                 ret_ref |= 1;
44048         }
44049         return ret_ref;
44050 }
44051
44052 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
44053         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
44054 int64_t ret_ref = 0;
44055 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44056 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44057 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44058 ret_ref = (uintptr_t)ret_var.inner;
44059 if (ret_var.is_owned) {
44060         ret_ref |= 1;
44061 }
44062         return ret_ref;
44063 }
44064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44065         LDKNodeAnnouncementInfo arg_conv;
44066         arg_conv.inner = (void*)(arg & (~1));
44067         arg_conv.is_owned = false;
44068         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44069         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
44070         return ret_conv;
44071 }
44072
44073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44074         LDKNodeAnnouncementInfo orig_conv;
44075         orig_conv.inner = (void*)(orig & (~1));
44076         orig_conv.is_owned = false;
44077         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44078         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
44079         int64_t ret_ref = 0;
44080         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44081         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44083         ret_ref = (uintptr_t)ret_var.inner;
44084         if (ret_var.is_owned) {
44085                 ret_ref |= 1;
44086         }
44087         return ret_ref;
44088 }
44089
44090 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
44091         LDKNodeAnnouncementInfo obj_conv;
44092         obj_conv.inner = (void*)(obj & (~1));
44093         obj_conv.is_owned = false;
44094         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44095         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
44096         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44097         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44098         CVec_u8Z_free(ret_var);
44099         return ret_arr;
44100 }
44101
44102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44103         LDKu8slice ser_ref;
44104         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44105         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44106         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
44107         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
44108         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44109         return (int64_t)ret_conv;
44110 }
44111
44112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44113         LDKNodeAlias this_obj_conv;
44114         this_obj_conv.inner = (void*)(this_obj & (~1));
44115         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44117         NodeAlias_free(this_obj_conv);
44118 }
44119
44120 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
44121         LDKNodeAlias 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44126         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAlias_get_a(&this_ptr_conv));
44127         return ret_arr;
44128 }
44129
44130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44131         LDKNodeAlias this_ptr_conv;
44132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44133         this_ptr_conv.is_owned = false;
44134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44135         LDKThirtyTwoBytes val_ref;
44136         CHECK((*env)->GetArrayLength(env, val) == 32);
44137         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
44138         NodeAlias_set_a(&this_ptr_conv, val_ref);
44139 }
44140
44141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
44142         LDKThirtyTwoBytes a_arg_ref;
44143         CHECK((*env)->GetArrayLength(env, a_arg) == 32);
44144         (*env)->GetByteArrayRegion(env, a_arg, 0, 32, a_arg_ref.data);
44145         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
44146         int64_t ret_ref = 0;
44147         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44148         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44150         ret_ref = (uintptr_t)ret_var.inner;
44151         if (ret_var.is_owned) {
44152                 ret_ref |= 1;
44153         }
44154         return ret_ref;
44155 }
44156
44157 static inline uintptr_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
44158         LDKNodeAlias ret_var = NodeAlias_clone(arg);
44159 int64_t ret_ref = 0;
44160 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44161 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44162 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44163 ret_ref = (uintptr_t)ret_var.inner;
44164 if (ret_var.is_owned) {
44165         ret_ref |= 1;
44166 }
44167         return ret_ref;
44168 }
44169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44170         LDKNodeAlias arg_conv;
44171         arg_conv.inner = (void*)(arg & (~1));
44172         arg_conv.is_owned = false;
44173         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44174         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
44175         return ret_conv;
44176 }
44177
44178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44179         LDKNodeAlias orig_conv;
44180         orig_conv.inner = (void*)(orig & (~1));
44181         orig_conv.is_owned = false;
44182         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44183         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
44184         int64_t ret_ref = 0;
44185         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44186         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44188         ret_ref = (uintptr_t)ret_var.inner;
44189         if (ret_var.is_owned) {
44190                 ret_ref |= 1;
44191         }
44192         return ret_ref;
44193 }
44194
44195 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1write(JNIEnv *env, jclass clz, int64_t obj) {
44196         LDKNodeAlias obj_conv;
44197         obj_conv.inner = (void*)(obj & (~1));
44198         obj_conv.is_owned = false;
44199         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44200         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
44201         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44202         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44203         CVec_u8Z_free(ret_var);
44204         return ret_arr;
44205 }
44206
44207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44208         LDKu8slice ser_ref;
44209         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44210         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44211         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
44212         *ret_conv = NodeAlias_read(ser_ref);
44213         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44214         return (int64_t)ret_conv;
44215 }
44216
44217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44218         LDKNodeInfo this_obj_conv;
44219         this_obj_conv.inner = (void*)(this_obj & (~1));
44220         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44222         NodeInfo_free(this_obj_conv);
44223 }
44224
44225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
44226         LDKNodeInfo this_ptr_conv;
44227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44228         this_ptr_conv.is_owned = false;
44229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44230         LDKCVec_u64Z val_constr;
44231         val_constr.datalen = (*env)->GetArrayLength(env, val);
44232         if (val_constr.datalen > 0)
44233                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
44234         else
44235                 val_constr.data = NULL;
44236         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
44237         for (size_t g = 0; g < val_constr.datalen; g++) {
44238                 int64_t val_conv_6 = val_vals[g];
44239                 val_constr.data[g] = val_conv_6;
44240         }
44241         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
44242         NodeInfo_set_channels(&this_ptr_conv, val_constr);
44243 }
44244
44245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
44246         LDKNodeInfo this_ptr_conv;
44247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44248         this_ptr_conv.is_owned = false;
44249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44250         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
44251         int64_t ret_ref = 0;
44252         if ((uintptr_t)ret_var.inner > 4096) {
44253                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44254                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44256                 ret_ref = (uintptr_t)ret_var.inner;
44257                 if (ret_var.is_owned) {
44258                         ret_ref |= 1;
44259                 }
44260         }
44261         return ret_ref;
44262 }
44263
44264 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) {
44265         LDKNodeInfo this_ptr_conv;
44266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44267         this_ptr_conv.is_owned = false;
44268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44269         LDKRoutingFees val_conv;
44270         val_conv.inner = (void*)(val & (~1));
44271         val_conv.is_owned = (val & 1) || (val == 0);
44272         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44273         val_conv = RoutingFees_clone(&val_conv);
44274         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
44275 }
44276
44277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
44278         LDKNodeInfo this_ptr_conv;
44279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44280         this_ptr_conv.is_owned = false;
44281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44282         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
44283         int64_t ret_ref = 0;
44284         if ((uintptr_t)ret_var.inner > 4096) {
44285                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44286                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44287         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44288                 ret_ref = (uintptr_t)ret_var.inner;
44289                 if (ret_var.is_owned) {
44290                         ret_ref |= 1;
44291                 }
44292         }
44293         return ret_ref;
44294 }
44295
44296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44297         LDKNodeInfo this_ptr_conv;
44298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44299         this_ptr_conv.is_owned = false;
44300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44301         LDKNodeAnnouncementInfo val_conv;
44302         val_conv.inner = (void*)(val & (~1));
44303         val_conv.is_owned = (val & 1) || (val == 0);
44304         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44305         val_conv = NodeAnnouncementInfo_clone(&val_conv);
44306         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
44307 }
44308
44309 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) {
44310         LDKCVec_u64Z channels_arg_constr;
44311         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
44312         if (channels_arg_constr.datalen > 0)
44313                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
44314         else
44315                 channels_arg_constr.data = NULL;
44316         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
44317         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
44318                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
44319                 channels_arg_constr.data[g] = channels_arg_conv_6;
44320         }
44321         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
44322         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
44323         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
44324         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
44325         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
44326         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
44327         LDKNodeAnnouncementInfo announcement_info_arg_conv;
44328         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
44329         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
44330         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
44331         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
44332         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
44333         int64_t ret_ref = 0;
44334         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44335         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44337         ret_ref = (uintptr_t)ret_var.inner;
44338         if (ret_var.is_owned) {
44339                 ret_ref |= 1;
44340         }
44341         return ret_ref;
44342 }
44343
44344 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
44345         LDKNodeInfo ret_var = NodeInfo_clone(arg);
44346 int64_t ret_ref = 0;
44347 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44348 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44349 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44350 ret_ref = (uintptr_t)ret_var.inner;
44351 if (ret_var.is_owned) {
44352         ret_ref |= 1;
44353 }
44354         return ret_ref;
44355 }
44356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44357         LDKNodeInfo arg_conv;
44358         arg_conv.inner = (void*)(arg & (~1));
44359         arg_conv.is_owned = false;
44360         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44361         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
44362         return ret_conv;
44363 }
44364
44365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44366         LDKNodeInfo orig_conv;
44367         orig_conv.inner = (void*)(orig & (~1));
44368         orig_conv.is_owned = false;
44369         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44370         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
44371         int64_t ret_ref = 0;
44372         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44373         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44375         ret_ref = (uintptr_t)ret_var.inner;
44376         if (ret_var.is_owned) {
44377                 ret_ref |= 1;
44378         }
44379         return ret_ref;
44380 }
44381
44382 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
44383         LDKNodeInfo obj_conv;
44384         obj_conv.inner = (void*)(obj & (~1));
44385         obj_conv.is_owned = false;
44386         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44387         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
44388         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44389         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44390         CVec_u8Z_free(ret_var);
44391         return ret_arr;
44392 }
44393
44394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44395         LDKu8slice ser_ref;
44396         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44397         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44398         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
44399         *ret_conv = NodeInfo_read(ser_ref);
44400         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44401         return (int64_t)ret_conv;
44402 }
44403
44404 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
44405         LDKNetworkGraph obj_conv;
44406         obj_conv.inner = (void*)(obj & (~1));
44407         obj_conv.is_owned = false;
44408         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44409         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
44410         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44411         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44412         CVec_u8Z_free(ret_var);
44413         return ret_arr;
44414 }
44415
44416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
44417         LDKu8slice ser_ref;
44418         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44419         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44420         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
44421         CHECK_ACCESS(arg_ptr);
44422         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
44423         if (arg_conv.free == LDKLogger_JCalls_free) {
44424                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44425                 LDKLogger_JCalls_cloned(&arg_conv);
44426         }
44427         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
44428         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
44429         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44430         return (int64_t)ret_conv;
44431 }
44432
44433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t logger) {
44434         LDKThirtyTwoBytes genesis_hash_ref;
44435         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
44436         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
44437         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
44438         CHECK_ACCESS(logger_ptr);
44439         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
44440         if (logger_conv.free == LDKLogger_JCalls_free) {
44441                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44442                 LDKLogger_JCalls_cloned(&logger_conv);
44443         }
44444         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
44445         int64_t ret_ref = 0;
44446         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44447         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44449         ret_ref = (uintptr_t)ret_var.inner;
44450         if (ret_var.is_owned) {
44451                 ret_ref |= 1;
44452         }
44453         return ret_ref;
44454 }
44455
44456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
44457         LDKNetworkGraph this_arg_conv;
44458         this_arg_conv.inner = (void*)(this_arg & (~1));
44459         this_arg_conv.is_owned = false;
44460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44461         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
44462         int64_t ret_ref = 0;
44463         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44464         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44466         ret_ref = (uintptr_t)ret_var.inner;
44467         if (ret_var.is_owned) {
44468                 ret_ref |= 1;
44469         }
44470         return ret_ref;
44471 }
44472
44473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1get_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
44474         LDKNetworkGraph this_arg_conv;
44475         this_arg_conv.inner = (void*)(this_arg & (~1));
44476         this_arg_conv.is_owned = false;
44477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44478         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
44479         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
44480         int64_t ret_ref = (uintptr_t)ret_copy;
44481         return ret_ref;
44482 }
44483
44484 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) {
44485         LDKNetworkGraph this_arg_conv;
44486         this_arg_conv.inner = (void*)(this_arg & (~1));
44487         this_arg_conv.is_owned = false;
44488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44489         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
44490 }
44491
44492 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) {
44493         LDKNetworkGraph this_arg_conv;
44494         this_arg_conv.inner = (void*)(this_arg & (~1));
44495         this_arg_conv.is_owned = false;
44496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44497         LDKNodeAnnouncement msg_conv;
44498         msg_conv.inner = (void*)(msg & (~1));
44499         msg_conv.is_owned = false;
44500         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44501         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44502         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
44503         return (int64_t)ret_conv;
44504 }
44505
44506 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) {
44507         LDKNetworkGraph this_arg_conv;
44508         this_arg_conv.inner = (void*)(this_arg & (~1));
44509         this_arg_conv.is_owned = false;
44510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44511         LDKUnsignedNodeAnnouncement msg_conv;
44512         msg_conv.inner = (void*)(msg & (~1));
44513         msg_conv.is_owned = false;
44514         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44515         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44516         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
44517         return (int64_t)ret_conv;
44518 }
44519
44520 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) {
44521         LDKNetworkGraph this_arg_conv;
44522         this_arg_conv.inner = (void*)(this_arg & (~1));
44523         this_arg_conv.is_owned = false;
44524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44525         LDKChannelAnnouncement msg_conv;
44526         msg_conv.inner = (void*)(msg & (~1));
44527         msg_conv.is_owned = false;
44528         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44529         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
44530         CHECK_ACCESS(chain_access_ptr);
44531         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
44532         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
44533         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
44534                 // Manually implement clone for Java trait instances
44535                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
44536                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44537                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
44538                 }
44539         }
44540         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44541         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
44542         return (int64_t)ret_conv;
44543 }
44544
44545 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) {
44546         LDKNetworkGraph this_arg_conv;
44547         this_arg_conv.inner = (void*)(this_arg & (~1));
44548         this_arg_conv.is_owned = false;
44549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44550         LDKUnsignedChannelAnnouncement msg_conv;
44551         msg_conv.inner = (void*)(msg & (~1));
44552         msg_conv.is_owned = false;
44553         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44554         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
44555         CHECK_ACCESS(chain_access_ptr);
44556         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
44557         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
44558         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
44559                 // Manually implement clone for Java trait instances
44560                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
44561                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44562                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
44563                 }
44564         }
44565         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44566         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
44567         return (int64_t)ret_conv;
44568 }
44569
44570 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) {
44571         LDKNetworkGraph this_arg_conv;
44572         this_arg_conv.inner = (void*)(this_arg & (~1));
44573         this_arg_conv.is_owned = false;
44574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44575         LDKChannelFeatures features_conv;
44576         features_conv.inner = (void*)(features & (~1));
44577         features_conv.is_owned = (features & 1) || (features == 0);
44578         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
44579         features_conv = ChannelFeatures_clone(&features_conv);
44580         LDKPublicKey node_id_1_ref;
44581         CHECK((*env)->GetArrayLength(env, node_id_1) == 33);
44582         (*env)->GetByteArrayRegion(env, node_id_1, 0, 33, node_id_1_ref.compressed_form);
44583         LDKPublicKey node_id_2_ref;
44584         CHECK((*env)->GetArrayLength(env, node_id_2) == 33);
44585         (*env)->GetByteArrayRegion(env, node_id_2, 0, 33, node_id_2_ref.compressed_form);
44586         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44587         *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);
44588         return (int64_t)ret_conv;
44589 }
44590
44591 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) {
44592         LDKNetworkGraph this_arg_conv;
44593         this_arg_conv.inner = (void*)(this_arg & (~1));
44594         this_arg_conv.is_owned = false;
44595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44596         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
44597 }
44598
44599 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) {
44600         LDKNetworkGraph this_arg_conv;
44601         this_arg_conv.inner = (void*)(this_arg & (~1));
44602         this_arg_conv.is_owned = false;
44603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44604         LDKPublicKey _node_id_ref;
44605         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
44606         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
44607         NetworkGraph_node_failed(&this_arg_conv, _node_id_ref, is_permanent);
44608 }
44609
44610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
44611         LDKNetworkGraph this_arg_conv;
44612         this_arg_conv.inner = (void*)(this_arg & (~1));
44613         this_arg_conv.is_owned = false;
44614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44615         NetworkGraph_remove_stale_channels(&this_arg_conv);
44616 }
44617
44618 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) {
44619         LDKNetworkGraph this_arg_conv;
44620         this_arg_conv.inner = (void*)(this_arg & (~1));
44621         this_arg_conv.is_owned = false;
44622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44623         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
44624 }
44625
44626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
44627         LDKNetworkGraph this_arg_conv;
44628         this_arg_conv.inner = (void*)(this_arg & (~1));
44629         this_arg_conv.is_owned = false;
44630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44631         LDKChannelUpdate msg_conv;
44632         msg_conv.inner = (void*)(msg & (~1));
44633         msg_conv.is_owned = false;
44634         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44635         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44636         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
44637         return (int64_t)ret_conv;
44638 }
44639
44640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
44641         LDKNetworkGraph this_arg_conv;
44642         this_arg_conv.inner = (void*)(this_arg & (~1));
44643         this_arg_conv.is_owned = false;
44644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44645         LDKUnsignedChannelUpdate msg_conv;
44646         msg_conv.inner = (void*)(msg & (~1));
44647         msg_conv.is_owned = false;
44648         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44649         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44650         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
44651         return (int64_t)ret_conv;
44652 }
44653
44654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
44655         LDKReadOnlyNetworkGraph this_arg_conv;
44656         this_arg_conv.inner = (void*)(this_arg & (~1));
44657         this_arg_conv.is_owned = false;
44658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44659         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
44660         int64_t ret_ref = 0;
44661         if ((uintptr_t)ret_var.inner > 4096) {
44662                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44663                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44664         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44665                 ret_ref = (uintptr_t)ret_var.inner;
44666                 if (ret_var.is_owned) {
44667                         ret_ref |= 1;
44668                 }
44669         }
44670         return ret_ref;
44671 }
44672
44673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1node(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
44674         LDKReadOnlyNetworkGraph this_arg_conv;
44675         this_arg_conv.inner = (void*)(this_arg & (~1));
44676         this_arg_conv.is_owned = false;
44677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44678         LDKNodeId node_id_conv;
44679         node_id_conv.inner = (void*)(node_id & (~1));
44680         node_id_conv.is_owned = false;
44681         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
44682         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
44683         int64_t ret_ref = 0;
44684         if ((uintptr_t)ret_var.inner > 4096) {
44685                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44686                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44687         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44688                 ret_ref = (uintptr_t)ret_var.inner;
44689                 if (ret_var.is_owned) {
44690                         ret_ref |= 1;
44691                 }
44692         }
44693         return ret_ref;
44694 }
44695
44696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
44697         LDKReadOnlyNetworkGraph this_arg_conv;
44698         this_arg_conv.inner = (void*)(this_arg & (~1));
44699         this_arg_conv.is_owned = false;
44700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44701         LDKPublicKey pubkey_ref;
44702         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
44703         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
44704         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
44705         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
44706         int64_t ret_ref = (uintptr_t)ret_copy;
44707         return ret_ref;
44708 }
44709
44710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44711         LDKRouteHop this_obj_conv;
44712         this_obj_conv.inner = (void*)(this_obj & (~1));
44713         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44715         RouteHop_free(this_obj_conv);
44716 }
44717
44718 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
44719         LDKRouteHop this_ptr_conv;
44720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44721         this_ptr_conv.is_owned = false;
44722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44723         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
44724         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
44725         return ret_arr;
44726 }
44727
44728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44729         LDKRouteHop this_ptr_conv;
44730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44731         this_ptr_conv.is_owned = false;
44732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44733         LDKPublicKey val_ref;
44734         CHECK((*env)->GetArrayLength(env, val) == 33);
44735         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
44736         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
44737 }
44738
44739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
44740         LDKRouteHop this_ptr_conv;
44741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44742         this_ptr_conv.is_owned = false;
44743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44744         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
44745         int64_t ret_ref = 0;
44746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44749         ret_ref = (uintptr_t)ret_var.inner;
44750         if (ret_var.is_owned) {
44751                 ret_ref |= 1;
44752         }
44753         return ret_ref;
44754 }
44755
44756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44757         LDKRouteHop this_ptr_conv;
44758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44759         this_ptr_conv.is_owned = false;
44760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44761         LDKNodeFeatures val_conv;
44762         val_conv.inner = (void*)(val & (~1));
44763         val_conv.is_owned = (val & 1) || (val == 0);
44764         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44765         val_conv = NodeFeatures_clone(&val_conv);
44766         RouteHop_set_node_features(&this_ptr_conv, val_conv);
44767 }
44768
44769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
44770         LDKRouteHop this_ptr_conv;
44771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44772         this_ptr_conv.is_owned = false;
44773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44774         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
44775         return ret_conv;
44776 }
44777
44778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44779         LDKRouteHop this_ptr_conv;
44780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44781         this_ptr_conv.is_owned = false;
44782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44783         RouteHop_set_short_channel_id(&this_ptr_conv, val);
44784 }
44785
44786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
44787         LDKRouteHop this_ptr_conv;
44788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44789         this_ptr_conv.is_owned = false;
44790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44791         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
44792         int64_t ret_ref = 0;
44793         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44794         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44796         ret_ref = (uintptr_t)ret_var.inner;
44797         if (ret_var.is_owned) {
44798                 ret_ref |= 1;
44799         }
44800         return ret_ref;
44801 }
44802
44803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44804         LDKRouteHop this_ptr_conv;
44805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44806         this_ptr_conv.is_owned = false;
44807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44808         LDKChannelFeatures val_conv;
44809         val_conv.inner = (void*)(val & (~1));
44810         val_conv.is_owned = (val & 1) || (val == 0);
44811         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44812         val_conv = ChannelFeatures_clone(&val_conv);
44813         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
44814 }
44815
44816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44817         LDKRouteHop this_ptr_conv;
44818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44819         this_ptr_conv.is_owned = false;
44820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44821         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
44822         return ret_conv;
44823 }
44824
44825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44826         LDKRouteHop this_ptr_conv;
44827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44828         this_ptr_conv.is_owned = false;
44829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44830         RouteHop_set_fee_msat(&this_ptr_conv, val);
44831 }
44832
44833 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
44834         LDKRouteHop this_ptr_conv;
44835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44836         this_ptr_conv.is_owned = false;
44837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44838         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
44839         return ret_conv;
44840 }
44841
44842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
44843         LDKRouteHop this_ptr_conv;
44844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44845         this_ptr_conv.is_owned = false;
44846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44847         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
44848 }
44849
44850 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) {
44851         LDKPublicKey pubkey_arg_ref;
44852         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
44853         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
44854         LDKNodeFeatures node_features_arg_conv;
44855         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
44856         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
44857         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
44858         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
44859         LDKChannelFeatures channel_features_arg_conv;
44860         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
44861         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
44862         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
44863         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
44864         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);
44865         int64_t ret_ref = 0;
44866         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44867         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44869         ret_ref = (uintptr_t)ret_var.inner;
44870         if (ret_var.is_owned) {
44871                 ret_ref |= 1;
44872         }
44873         return ret_ref;
44874 }
44875
44876 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
44877         LDKRouteHop ret_var = RouteHop_clone(arg);
44878 int64_t ret_ref = 0;
44879 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44880 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44881 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44882 ret_ref = (uintptr_t)ret_var.inner;
44883 if (ret_var.is_owned) {
44884         ret_ref |= 1;
44885 }
44886         return ret_ref;
44887 }
44888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44889         LDKRouteHop arg_conv;
44890         arg_conv.inner = (void*)(arg & (~1));
44891         arg_conv.is_owned = false;
44892         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44893         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
44894         return ret_conv;
44895 }
44896
44897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44898         LDKRouteHop orig_conv;
44899         orig_conv.inner = (void*)(orig & (~1));
44900         orig_conv.is_owned = false;
44901         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44902         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
44903         int64_t ret_ref = 0;
44904         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44905         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44907         ret_ref = (uintptr_t)ret_var.inner;
44908         if (ret_var.is_owned) {
44909                 ret_ref |= 1;
44910         }
44911         return ret_ref;
44912 }
44913
44914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
44915         LDKRouteHop o_conv;
44916         o_conv.inner = (void*)(o & (~1));
44917         o_conv.is_owned = false;
44918         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44919         int64_t ret_conv = RouteHop_hash(&o_conv);
44920         return ret_conv;
44921 }
44922
44923 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44924         LDKRouteHop a_conv;
44925         a_conv.inner = (void*)(a & (~1));
44926         a_conv.is_owned = false;
44927         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44928         LDKRouteHop b_conv;
44929         b_conv.inner = (void*)(b & (~1));
44930         b_conv.is_owned = false;
44931         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44932         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
44933         return ret_conv;
44934 }
44935
44936 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
44937         LDKRouteHop obj_conv;
44938         obj_conv.inner = (void*)(obj & (~1));
44939         obj_conv.is_owned = false;
44940         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44941         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
44942         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44943         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44944         CVec_u8Z_free(ret_var);
44945         return ret_arr;
44946 }
44947
44948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44949         LDKu8slice ser_ref;
44950         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44951         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44952         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
44953         *ret_conv = RouteHop_read(ser_ref);
44954         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44955         return (int64_t)ret_conv;
44956 }
44957
44958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44959         LDKRoute this_obj_conv;
44960         this_obj_conv.inner = (void*)(this_obj & (~1));
44961         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44963         Route_free(this_obj_conv);
44964 }
44965
44966 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
44967         LDKRoute this_ptr_conv;
44968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44969         this_ptr_conv.is_owned = false;
44970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44971         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
44972         jobjectArray ret_arr = NULL;
44973         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
44974         ;
44975         for (size_t m = 0; m < ret_var.datalen; m++) {
44976                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
44977                 int64_tArray ret_conv_12_arr = NULL;
44978                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
44979                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
44980                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
44981                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
44982                         int64_t ret_conv_12_conv_10_ref = 0;
44983                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44984                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44985                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
44986                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
44987                         if (ret_conv_12_conv_10_var.is_owned) {
44988                                 ret_conv_12_conv_10_ref |= 1;
44989                         }
44990                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
44991                 }
44992                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
44993                 FREE(ret_conv_12_var.data);
44994                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
44995         }
44996         
44997         FREE(ret_var.data);
44998         return ret_arr;
44999 }
45000
45001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
45002         LDKRoute this_ptr_conv;
45003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45004         this_ptr_conv.is_owned = false;
45005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45006         LDKCVec_CVec_RouteHopZZ val_constr;
45007         val_constr.datalen = (*env)->GetArrayLength(env, val);
45008         if (val_constr.datalen > 0)
45009                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
45010         else
45011                 val_constr.data = NULL;
45012         for (size_t m = 0; m < val_constr.datalen; m++) {
45013                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
45014                 LDKCVec_RouteHopZ val_conv_12_constr;
45015                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
45016                 if (val_conv_12_constr.datalen > 0)
45017                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
45018                 else
45019                         val_conv_12_constr.data = NULL;
45020                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
45021                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
45022                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
45023                         LDKRouteHop val_conv_12_conv_10_conv;
45024                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
45025                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
45026                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
45027                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
45028                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
45029                 }
45030                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
45031                 val_constr.data[m] = val_conv_12_constr;
45032         }
45033         Route_set_paths(&this_ptr_conv, val_constr);
45034 }
45035
45036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
45037         LDKRoute this_ptr_conv;
45038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45039         this_ptr_conv.is_owned = false;
45040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45041         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
45042         int64_t ret_ref = 0;
45043         if ((uintptr_t)ret_var.inner > 4096) {
45044                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45045                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45047                 ret_ref = (uintptr_t)ret_var.inner;
45048                 if (ret_var.is_owned) {
45049                         ret_ref |= 1;
45050                 }
45051         }
45052         return ret_ref;
45053 }
45054
45055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45056         LDKRoute this_ptr_conv;
45057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45058         this_ptr_conv.is_owned = false;
45059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45060         LDKPaymentParameters val_conv;
45061         val_conv.inner = (void*)(val & (~1));
45062         val_conv.is_owned = (val & 1) || (val == 0);
45063         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45064         val_conv = PaymentParameters_clone(&val_conv);
45065         Route_set_payment_params(&this_ptr_conv, val_conv);
45066 }
45067
45068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
45069         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
45070         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
45071         if (paths_arg_constr.datalen > 0)
45072                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
45073         else
45074                 paths_arg_constr.data = NULL;
45075         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
45076                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
45077                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
45078                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
45079                 if (paths_arg_conv_12_constr.datalen > 0)
45080                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
45081                 else
45082                         paths_arg_conv_12_constr.data = NULL;
45083                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
45084                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
45085                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
45086                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
45087                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
45088                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
45089                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
45090                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
45091                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
45092                 }
45093                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
45094                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
45095         }
45096         LDKPaymentParameters payment_params_arg_conv;
45097         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
45098         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
45099         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
45100         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
45101         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
45102         int64_t ret_ref = 0;
45103         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45104         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45106         ret_ref = (uintptr_t)ret_var.inner;
45107         if (ret_var.is_owned) {
45108                 ret_ref |= 1;
45109         }
45110         return ret_ref;
45111 }
45112
45113 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
45114         LDKRoute ret_var = Route_clone(arg);
45115 int64_t ret_ref = 0;
45116 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45117 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45118 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45119 ret_ref = (uintptr_t)ret_var.inner;
45120 if (ret_var.is_owned) {
45121         ret_ref |= 1;
45122 }
45123         return ret_ref;
45124 }
45125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45126         LDKRoute arg_conv;
45127         arg_conv.inner = (void*)(arg & (~1));
45128         arg_conv.is_owned = false;
45129         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45130         int64_t ret_conv = Route_clone_ptr(&arg_conv);
45131         return ret_conv;
45132 }
45133
45134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45135         LDKRoute orig_conv;
45136         orig_conv.inner = (void*)(orig & (~1));
45137         orig_conv.is_owned = false;
45138         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45139         LDKRoute ret_var = Route_clone(&orig_conv);
45140         int64_t ret_ref = 0;
45141         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45142         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45144         ret_ref = (uintptr_t)ret_var.inner;
45145         if (ret_var.is_owned) {
45146                 ret_ref |= 1;
45147         }
45148         return ret_ref;
45149 }
45150
45151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
45152         LDKRoute o_conv;
45153         o_conv.inner = (void*)(o & (~1));
45154         o_conv.is_owned = false;
45155         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45156         int64_t ret_conv = Route_hash(&o_conv);
45157         return ret_conv;
45158 }
45159
45160 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45161         LDKRoute a_conv;
45162         a_conv.inner = (void*)(a & (~1));
45163         a_conv.is_owned = false;
45164         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45165         LDKRoute b_conv;
45166         b_conv.inner = (void*)(b & (~1));
45167         b_conv.is_owned = false;
45168         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45169         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
45170         return ret_conv;
45171 }
45172
45173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
45174         LDKRoute this_arg_conv;
45175         this_arg_conv.inner = (void*)(this_arg & (~1));
45176         this_arg_conv.is_owned = false;
45177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45178         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
45179         return ret_conv;
45180 }
45181
45182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
45183         LDKRoute this_arg_conv;
45184         this_arg_conv.inner = (void*)(this_arg & (~1));
45185         this_arg_conv.is_owned = false;
45186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45187         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
45188         return ret_conv;
45189 }
45190
45191 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
45192         LDKRoute obj_conv;
45193         obj_conv.inner = (void*)(obj & (~1));
45194         obj_conv.is_owned = false;
45195         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45196         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
45197         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45198         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45199         CVec_u8Z_free(ret_var);
45200         return ret_arr;
45201 }
45202
45203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45204         LDKu8slice ser_ref;
45205         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45206         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45207         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
45208         *ret_conv = Route_read(ser_ref);
45209         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45210         return (int64_t)ret_conv;
45211 }
45212
45213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45214         LDKRouteParameters this_obj_conv;
45215         this_obj_conv.inner = (void*)(this_obj & (~1));
45216         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45218         RouteParameters_free(this_obj_conv);
45219 }
45220
45221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
45222         LDKRouteParameters this_ptr_conv;
45223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45224         this_ptr_conv.is_owned = false;
45225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45226         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
45227         int64_t ret_ref = 0;
45228         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45229         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45231         ret_ref = (uintptr_t)ret_var.inner;
45232         if (ret_var.is_owned) {
45233                 ret_ref |= 1;
45234         }
45235         return ret_ref;
45236 }
45237
45238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45239         LDKRouteParameters this_ptr_conv;
45240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45241         this_ptr_conv.is_owned = false;
45242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45243         LDKPaymentParameters val_conv;
45244         val_conv.inner = (void*)(val & (~1));
45245         val_conv.is_owned = (val & 1) || (val == 0);
45246         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45247         val_conv = PaymentParameters_clone(&val_conv);
45248         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
45249 }
45250
45251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45252         LDKRouteParameters this_ptr_conv;
45253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45254         this_ptr_conv.is_owned = false;
45255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45256         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
45257         return ret_conv;
45258 }
45259
45260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45261         LDKRouteParameters this_ptr_conv;
45262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45263         this_ptr_conv.is_owned = false;
45264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45265         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
45266 }
45267
45268 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
45269         LDKRouteParameters this_ptr_conv;
45270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45271         this_ptr_conv.is_owned = false;
45272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45273         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
45274         return ret_conv;
45275 }
45276
45277 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) {
45278         LDKRouteParameters this_ptr_conv;
45279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45280         this_ptr_conv.is_owned = false;
45281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45282         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
45283 }
45284
45285 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) {
45286         LDKPaymentParameters payment_params_arg_conv;
45287         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
45288         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
45289         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
45290         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
45291         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
45292         int64_t ret_ref = 0;
45293         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45294         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45296         ret_ref = (uintptr_t)ret_var.inner;
45297         if (ret_var.is_owned) {
45298                 ret_ref |= 1;
45299         }
45300         return ret_ref;
45301 }
45302
45303 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
45304         LDKRouteParameters ret_var = RouteParameters_clone(arg);
45305 int64_t ret_ref = 0;
45306 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45307 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45308 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45309 ret_ref = (uintptr_t)ret_var.inner;
45310 if (ret_var.is_owned) {
45311         ret_ref |= 1;
45312 }
45313         return ret_ref;
45314 }
45315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45316         LDKRouteParameters arg_conv;
45317         arg_conv.inner = (void*)(arg & (~1));
45318         arg_conv.is_owned = false;
45319         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45320         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
45321         return ret_conv;
45322 }
45323
45324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45325         LDKRouteParameters orig_conv;
45326         orig_conv.inner = (void*)(orig & (~1));
45327         orig_conv.is_owned = false;
45328         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45329         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
45330         int64_t ret_ref = 0;
45331         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45332         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45334         ret_ref = (uintptr_t)ret_var.inner;
45335         if (ret_var.is_owned) {
45336                 ret_ref |= 1;
45337         }
45338         return ret_ref;
45339 }
45340
45341 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
45342         LDKRouteParameters obj_conv;
45343         obj_conv.inner = (void*)(obj & (~1));
45344         obj_conv.is_owned = false;
45345         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45346         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
45347         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45348         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45349         CVec_u8Z_free(ret_var);
45350         return ret_arr;
45351 }
45352
45353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45354         LDKu8slice ser_ref;
45355         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45356         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45357         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
45358         *ret_conv = RouteParameters_read(ser_ref);
45359         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45360         return (int64_t)ret_conv;
45361 }
45362
45363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45364         LDKPaymentParameters this_obj_conv;
45365         this_obj_conv.inner = (void*)(this_obj & (~1));
45366         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45368         PaymentParameters_free(this_obj_conv);
45369 }
45370
45371 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
45372         LDKPaymentParameters this_ptr_conv;
45373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45374         this_ptr_conv.is_owned = false;
45375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45376         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
45377         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
45378         return ret_arr;
45379 }
45380
45381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
45382         LDKPaymentParameters this_ptr_conv;
45383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45384         this_ptr_conv.is_owned = false;
45385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45386         LDKPublicKey val_ref;
45387         CHECK((*env)->GetArrayLength(env, val) == 33);
45388         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
45389         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
45390 }
45391
45392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
45393         LDKPaymentParameters this_ptr_conv;
45394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45395         this_ptr_conv.is_owned = false;
45396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45397         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
45398         int64_t ret_ref = 0;
45399         if ((uintptr_t)ret_var.inner > 4096) {
45400                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45401                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45403                 ret_ref = (uintptr_t)ret_var.inner;
45404                 if (ret_var.is_owned) {
45405                         ret_ref |= 1;
45406                 }
45407         }
45408         return ret_ref;
45409 }
45410
45411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45412         LDKPaymentParameters this_ptr_conv;
45413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45414         this_ptr_conv.is_owned = false;
45415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45416         LDKInvoiceFeatures val_conv;
45417         val_conv.inner = (void*)(val & (~1));
45418         val_conv.is_owned = (val & 1) || (val == 0);
45419         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45420         val_conv = InvoiceFeatures_clone(&val_conv);
45421         PaymentParameters_set_features(&this_ptr_conv, val_conv);
45422 }
45423
45424 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
45425         LDKPaymentParameters this_ptr_conv;
45426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45427         this_ptr_conv.is_owned = false;
45428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45429         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
45430         int64_tArray ret_arr = NULL;
45431         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45432         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45433         for (size_t l = 0; l < ret_var.datalen; l++) {
45434                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
45435                 int64_t ret_conv_11_ref = 0;
45436                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45437                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45438                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
45439                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
45440                 if (ret_conv_11_var.is_owned) {
45441                         ret_conv_11_ref |= 1;
45442                 }
45443                 ret_arr_ptr[l] = ret_conv_11_ref;
45444         }
45445         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45446         FREE(ret_var.data);
45447         return ret_arr;
45448 }
45449
45450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
45451         LDKPaymentParameters this_ptr_conv;
45452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45453         this_ptr_conv.is_owned = false;
45454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45455         LDKCVec_RouteHintZ val_constr;
45456         val_constr.datalen = (*env)->GetArrayLength(env, val);
45457         if (val_constr.datalen > 0)
45458                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
45459         else
45460                 val_constr.data = NULL;
45461         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
45462         for (size_t l = 0; l < val_constr.datalen; l++) {
45463                 int64_t val_conv_11 = val_vals[l];
45464                 LDKRouteHint val_conv_11_conv;
45465                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
45466                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
45467                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
45468                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
45469                 val_constr.data[l] = val_conv_11_conv;
45470         }
45471         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
45472         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
45473 }
45474
45475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
45476         LDKPaymentParameters this_ptr_conv;
45477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45478         this_ptr_conv.is_owned = false;
45479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45480         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45481         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
45482         int64_t ret_ref = (uintptr_t)ret_copy;
45483         return ret_ref;
45484 }
45485
45486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45487         LDKPaymentParameters this_ptr_conv;
45488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45489         this_ptr_conv.is_owned = false;
45490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45491         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
45492         CHECK_ACCESS(val_ptr);
45493         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
45494         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
45495         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
45496 }
45497
45498 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
45499         LDKPaymentParameters this_ptr_conv;
45500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45501         this_ptr_conv.is_owned = false;
45502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45503         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
45504         return ret_conv;
45505 }
45506
45507 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) {
45508         LDKPaymentParameters this_ptr_conv;
45509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45510         this_ptr_conv.is_owned = false;
45511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45512         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
45513 }
45514
45515 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr) {
45516         LDKPaymentParameters this_ptr_conv;
45517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45518         this_ptr_conv.is_owned = false;
45519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45520         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
45521         return ret_conv;
45522 }
45523
45524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
45525         LDKPaymentParameters this_ptr_conv;
45526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45527         this_ptr_conv.is_owned = false;
45528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45529         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
45530 }
45531
45532 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) {
45533         LDKPaymentParameters this_ptr_conv;
45534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45535         this_ptr_conv.is_owned = false;
45536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45537         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
45538         return ret_conv;
45539 }
45540
45541 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) {
45542         LDKPaymentParameters this_ptr_conv;
45543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45544         this_ptr_conv.is_owned = false;
45545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45546         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
45547 }
45548
45549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
45550         LDKPaymentParameters this_ptr_conv;
45551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45552         this_ptr_conv.is_owned = false;
45553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45554         LDKCVec_u64Z val_constr;
45555         val_constr.datalen = (*env)->GetArrayLength(env, val);
45556         if (val_constr.datalen > 0)
45557                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
45558         else
45559                 val_constr.data = NULL;
45560         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
45561         for (size_t g = 0; g < val_constr.datalen; g++) {
45562                 int64_t val_conv_6 = val_vals[g];
45563                 val_constr.data[g] = val_conv_6;
45564         }
45565         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
45566         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
45567 }
45568
45569 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) {
45570         LDKPublicKey payee_pubkey_arg_ref;
45571         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
45572         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
45573         LDKInvoiceFeatures features_arg_conv;
45574         features_arg_conv.inner = (void*)(features_arg & (~1));
45575         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
45576         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
45577         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
45578         LDKCVec_RouteHintZ route_hints_arg_constr;
45579         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
45580         if (route_hints_arg_constr.datalen > 0)
45581                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
45582         else
45583                 route_hints_arg_constr.data = NULL;
45584         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
45585         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
45586                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
45587                 LDKRouteHint route_hints_arg_conv_11_conv;
45588                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
45589                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
45590                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
45591                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
45592                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
45593         }
45594         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
45595         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
45596         CHECK_ACCESS(expiry_time_arg_ptr);
45597         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
45598         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
45599         LDKCVec_u64Z previously_failed_channels_arg_constr;
45600         previously_failed_channels_arg_constr.datalen = (*env)->GetArrayLength(env, previously_failed_channels_arg);
45601         if (previously_failed_channels_arg_constr.datalen > 0)
45602                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
45603         else
45604                 previously_failed_channels_arg_constr.data = NULL;
45605         int64_t* previously_failed_channels_arg_vals = (*env)->GetLongArrayElements (env, previously_failed_channels_arg, NULL);
45606         for (size_t g = 0; g < previously_failed_channels_arg_constr.datalen; g++) {
45607                 int64_t previously_failed_channels_arg_conv_6 = previously_failed_channels_arg_vals[g];
45608                 previously_failed_channels_arg_constr.data[g] = previously_failed_channels_arg_conv_6;
45609         }
45610         (*env)->ReleaseLongArrayElements(env, previously_failed_channels_arg, previously_failed_channels_arg_vals, 0);
45611         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);
45612         int64_t ret_ref = 0;
45613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45616         ret_ref = (uintptr_t)ret_var.inner;
45617         if (ret_var.is_owned) {
45618                 ret_ref |= 1;
45619         }
45620         return ret_ref;
45621 }
45622
45623 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
45624         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
45625 int64_t ret_ref = 0;
45626 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45627 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45628 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45629 ret_ref = (uintptr_t)ret_var.inner;
45630 if (ret_var.is_owned) {
45631         ret_ref |= 1;
45632 }
45633         return ret_ref;
45634 }
45635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45636         LDKPaymentParameters arg_conv;
45637         arg_conv.inner = (void*)(arg & (~1));
45638         arg_conv.is_owned = false;
45639         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45640         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
45641         return ret_conv;
45642 }
45643
45644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45645         LDKPaymentParameters orig_conv;
45646         orig_conv.inner = (void*)(orig & (~1));
45647         orig_conv.is_owned = false;
45648         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45649         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
45650         int64_t ret_ref = 0;
45651         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45652         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45654         ret_ref = (uintptr_t)ret_var.inner;
45655         if (ret_var.is_owned) {
45656                 ret_ref |= 1;
45657         }
45658         return ret_ref;
45659 }
45660
45661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
45662         LDKPaymentParameters o_conv;
45663         o_conv.inner = (void*)(o & (~1));
45664         o_conv.is_owned = false;
45665         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45666         int64_t ret_conv = PaymentParameters_hash(&o_conv);
45667         return ret_conv;
45668 }
45669
45670 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45671         LDKPaymentParameters a_conv;
45672         a_conv.inner = (void*)(a & (~1));
45673         a_conv.is_owned = false;
45674         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45675         LDKPaymentParameters b_conv;
45676         b_conv.inner = (void*)(b & (~1));
45677         b_conv.is_owned = false;
45678         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45679         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
45680         return ret_conv;
45681 }
45682
45683 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
45684         LDKPaymentParameters obj_conv;
45685         obj_conv.inner = (void*)(obj & (~1));
45686         obj_conv.is_owned = false;
45687         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45688         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
45689         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45690         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45691         CVec_u8Z_free(ret_var);
45692         return ret_arr;
45693 }
45694
45695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45696         LDKu8slice ser_ref;
45697         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45698         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45699         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
45700         *ret_conv = PaymentParameters_read(ser_ref);
45701         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45702         return (int64_t)ret_conv;
45703 }
45704
45705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
45706         LDKPublicKey payee_pubkey_ref;
45707         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
45708         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
45709         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
45710         int64_t ret_ref = 0;
45711         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45712         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45714         ret_ref = (uintptr_t)ret_var.inner;
45715         if (ret_var.is_owned) {
45716                 ret_ref |= 1;
45717         }
45718         return ret_ref;
45719 }
45720
45721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
45722         LDKPublicKey payee_pubkey_ref;
45723         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
45724         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
45725         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
45726         int64_t ret_ref = 0;
45727         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45728         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45730         ret_ref = (uintptr_t)ret_var.inner;
45731         if (ret_var.is_owned) {
45732                 ret_ref |= 1;
45733         }
45734         return ret_ref;
45735 }
45736
45737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45738         LDKRouteHint this_obj_conv;
45739         this_obj_conv.inner = (void*)(this_obj & (~1));
45740         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45742         RouteHint_free(this_obj_conv);
45743 }
45744
45745 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
45746         LDKRouteHint this_ptr_conv;
45747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45748         this_ptr_conv.is_owned = false;
45749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45750         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
45751         int64_tArray ret_arr = NULL;
45752         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45753         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45754         for (size_t o = 0; o < ret_var.datalen; o++) {
45755                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
45756                 int64_t ret_conv_14_ref = 0;
45757                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45758                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45759                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
45760                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
45761                 if (ret_conv_14_var.is_owned) {
45762                         ret_conv_14_ref |= 1;
45763                 }
45764                 ret_arr_ptr[o] = ret_conv_14_ref;
45765         }
45766         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45767         FREE(ret_var.data);
45768         return ret_arr;
45769 }
45770
45771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
45772         LDKRouteHint this_ptr_conv;
45773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45774         this_ptr_conv.is_owned = false;
45775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45776         LDKCVec_RouteHintHopZ val_constr;
45777         val_constr.datalen = (*env)->GetArrayLength(env, val);
45778         if (val_constr.datalen > 0)
45779                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
45780         else
45781                 val_constr.data = NULL;
45782         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
45783         for (size_t o = 0; o < val_constr.datalen; o++) {
45784                 int64_t val_conv_14 = val_vals[o];
45785                 LDKRouteHintHop val_conv_14_conv;
45786                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
45787                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
45788                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
45789                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
45790                 val_constr.data[o] = val_conv_14_conv;
45791         }
45792         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
45793         RouteHint_set_a(&this_ptr_conv, val_constr);
45794 }
45795
45796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
45797         LDKCVec_RouteHintHopZ a_arg_constr;
45798         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
45799         if (a_arg_constr.datalen > 0)
45800                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
45801         else
45802                 a_arg_constr.data = NULL;
45803         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
45804         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
45805                 int64_t a_arg_conv_14 = a_arg_vals[o];
45806                 LDKRouteHintHop a_arg_conv_14_conv;
45807                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
45808                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
45809                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
45810                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
45811                 a_arg_constr.data[o] = a_arg_conv_14_conv;
45812         }
45813         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
45814         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
45815         int64_t ret_ref = 0;
45816         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45817         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45819         ret_ref = (uintptr_t)ret_var.inner;
45820         if (ret_var.is_owned) {
45821                 ret_ref |= 1;
45822         }
45823         return ret_ref;
45824 }
45825
45826 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
45827         LDKRouteHint ret_var = RouteHint_clone(arg);
45828 int64_t ret_ref = 0;
45829 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45830 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45831 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45832 ret_ref = (uintptr_t)ret_var.inner;
45833 if (ret_var.is_owned) {
45834         ret_ref |= 1;
45835 }
45836         return ret_ref;
45837 }
45838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45839         LDKRouteHint arg_conv;
45840         arg_conv.inner = (void*)(arg & (~1));
45841         arg_conv.is_owned = false;
45842         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45843         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
45844         return ret_conv;
45845 }
45846
45847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45848         LDKRouteHint orig_conv;
45849         orig_conv.inner = (void*)(orig & (~1));
45850         orig_conv.is_owned = false;
45851         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45852         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
45853         int64_t ret_ref = 0;
45854         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45855         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45857         ret_ref = (uintptr_t)ret_var.inner;
45858         if (ret_var.is_owned) {
45859                 ret_ref |= 1;
45860         }
45861         return ret_ref;
45862 }
45863
45864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
45865         LDKRouteHint o_conv;
45866         o_conv.inner = (void*)(o & (~1));
45867         o_conv.is_owned = false;
45868         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45869         int64_t ret_conv = RouteHint_hash(&o_conv);
45870         return ret_conv;
45871 }
45872
45873 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45874         LDKRouteHint a_conv;
45875         a_conv.inner = (void*)(a & (~1));
45876         a_conv.is_owned = false;
45877         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45878         LDKRouteHint b_conv;
45879         b_conv.inner = (void*)(b & (~1));
45880         b_conv.is_owned = false;
45881         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45882         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
45883         return ret_conv;
45884 }
45885
45886 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
45887         LDKRouteHint obj_conv;
45888         obj_conv.inner = (void*)(obj & (~1));
45889         obj_conv.is_owned = false;
45890         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45891         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
45892         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45893         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45894         CVec_u8Z_free(ret_var);
45895         return ret_arr;
45896 }
45897
45898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45899         LDKu8slice ser_ref;
45900         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45901         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45902         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
45903         *ret_conv = RouteHint_read(ser_ref);
45904         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45905         return (int64_t)ret_conv;
45906 }
45907
45908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45909         LDKRouteHintHop this_obj_conv;
45910         this_obj_conv.inner = (void*)(this_obj & (~1));
45911         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45913         RouteHintHop_free(this_obj_conv);
45914 }
45915
45916 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
45917         LDKRouteHintHop this_ptr_conv;
45918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45919         this_ptr_conv.is_owned = false;
45920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45921         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
45922         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
45923         return ret_arr;
45924 }
45925
45926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
45927         LDKRouteHintHop this_ptr_conv;
45928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45929         this_ptr_conv.is_owned = false;
45930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45931         LDKPublicKey val_ref;
45932         CHECK((*env)->GetArrayLength(env, val) == 33);
45933         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
45934         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
45935 }
45936
45937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
45938         LDKRouteHintHop this_ptr_conv;
45939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45940         this_ptr_conv.is_owned = false;
45941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45942         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
45943         return ret_conv;
45944 }
45945
45946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45947         LDKRouteHintHop this_ptr_conv;
45948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45949         this_ptr_conv.is_owned = false;
45950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45951         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
45952 }
45953
45954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
45955         LDKRouteHintHop this_ptr_conv;
45956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45957         this_ptr_conv.is_owned = false;
45958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45959         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
45960         int64_t ret_ref = 0;
45961         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45962         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45964         ret_ref = (uintptr_t)ret_var.inner;
45965         if (ret_var.is_owned) {
45966                 ret_ref |= 1;
45967         }
45968         return ret_ref;
45969 }
45970
45971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45972         LDKRouteHintHop 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         LDKRoutingFees val_conv;
45977         val_conv.inner = (void*)(val & (~1));
45978         val_conv.is_owned = (val & 1) || (val == 0);
45979         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45980         val_conv = RoutingFees_clone(&val_conv);
45981         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
45982 }
45983
45984 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
45985         LDKRouteHintHop this_ptr_conv;
45986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45987         this_ptr_conv.is_owned = false;
45988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45989         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
45990         return ret_conv;
45991 }
45992
45993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
45994         LDKRouteHintHop this_ptr_conv;
45995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45996         this_ptr_conv.is_owned = false;
45997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45998         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
45999 }
46000
46001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46002         LDKRouteHintHop this_ptr_conv;
46003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46004         this_ptr_conv.is_owned = false;
46005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46006         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
46007         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
46008         int64_t ret_ref = (uintptr_t)ret_copy;
46009         return ret_ref;
46010 }
46011
46012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46013         LDKRouteHintHop this_ptr_conv;
46014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46015         this_ptr_conv.is_owned = false;
46016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46017         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
46018         CHECK_ACCESS(val_ptr);
46019         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
46020         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
46021         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
46022 }
46023
46024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46025         LDKRouteHintHop this_ptr_conv;
46026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46027         this_ptr_conv.is_owned = false;
46028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46029         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
46030         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
46031         int64_t ret_ref = (uintptr_t)ret_copy;
46032         return ret_ref;
46033 }
46034
46035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46036         LDKRouteHintHop this_ptr_conv;
46037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46038         this_ptr_conv.is_owned = false;
46039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46040         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
46041         CHECK_ACCESS(val_ptr);
46042         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
46043         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
46044         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
46045 }
46046
46047 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) {
46048         LDKPublicKey src_node_id_arg_ref;
46049         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
46050         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
46051         LDKRoutingFees fees_arg_conv;
46052         fees_arg_conv.inner = (void*)(fees_arg & (~1));
46053         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
46054         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
46055         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
46056         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
46057         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
46058         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
46059         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
46060         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
46061         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
46062         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
46063         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
46064         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);
46065         int64_t ret_ref = 0;
46066         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46067         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46069         ret_ref = (uintptr_t)ret_var.inner;
46070         if (ret_var.is_owned) {
46071                 ret_ref |= 1;
46072         }
46073         return ret_ref;
46074 }
46075
46076 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
46077         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
46078 int64_t ret_ref = 0;
46079 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46080 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46081 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46082 ret_ref = (uintptr_t)ret_var.inner;
46083 if (ret_var.is_owned) {
46084         ret_ref |= 1;
46085 }
46086         return ret_ref;
46087 }
46088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46089         LDKRouteHintHop arg_conv;
46090         arg_conv.inner = (void*)(arg & (~1));
46091         arg_conv.is_owned = false;
46092         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46093         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
46094         return ret_conv;
46095 }
46096
46097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46098         LDKRouteHintHop orig_conv;
46099         orig_conv.inner = (void*)(orig & (~1));
46100         orig_conv.is_owned = false;
46101         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46102         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
46103         int64_t ret_ref = 0;
46104         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46105         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46107         ret_ref = (uintptr_t)ret_var.inner;
46108         if (ret_var.is_owned) {
46109                 ret_ref |= 1;
46110         }
46111         return ret_ref;
46112 }
46113
46114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
46115         LDKRouteHintHop o_conv;
46116         o_conv.inner = (void*)(o & (~1));
46117         o_conv.is_owned = false;
46118         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46119         int64_t ret_conv = RouteHintHop_hash(&o_conv);
46120         return ret_conv;
46121 }
46122
46123 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46124         LDKRouteHintHop a_conv;
46125         a_conv.inner = (void*)(a & (~1));
46126         a_conv.is_owned = false;
46127         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46128         LDKRouteHintHop b_conv;
46129         b_conv.inner = (void*)(b & (~1));
46130         b_conv.is_owned = false;
46131         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46132         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
46133         return ret_conv;
46134 }
46135
46136 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
46137         LDKRouteHintHop obj_conv;
46138         obj_conv.inner = (void*)(obj & (~1));
46139         obj_conv.is_owned = false;
46140         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46141         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
46142         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46143         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46144         CVec_u8Z_free(ret_var);
46145         return ret_arr;
46146 }
46147
46148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46149         LDKu8slice ser_ref;
46150         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46151         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46152         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
46153         *ret_conv = RouteHintHop_read(ser_ref);
46154         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46155         return (int64_t)ret_conv;
46156 }
46157
46158 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) {
46159         LDKPublicKey our_node_pubkey_ref;
46160         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
46161         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
46162         LDKRouteParameters route_params_conv;
46163         route_params_conv.inner = (void*)(route_params & (~1));
46164         route_params_conv.is_owned = false;
46165         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
46166         LDKNetworkGraph network_graph_conv;
46167         network_graph_conv.inner = (void*)(network_graph & (~1));
46168         network_graph_conv.is_owned = false;
46169         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46170         LDKCVec_ChannelDetailsZ first_hops_constr;
46171         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
46172         if (first_hops != NULL) {
46173                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
46174                 if (first_hops_constr.datalen > 0)
46175                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
46176                 else
46177                         first_hops_constr.data = NULL;
46178                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
46179                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
46180                         int64_t first_hops_conv_16 = first_hops_vals[q];
46181                         LDKChannelDetails first_hops_conv_16_conv;
46182                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
46183                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
46184                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
46185                         first_hops_constr.data[q] = first_hops_conv_16_conv;
46186                 }
46187                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
46188                 first_hops_ptr = &first_hops_constr;
46189         }
46190         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
46191         CHECK_ACCESS(logger_ptr);
46192         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46193         if (logger_conv.free == LDKLogger_JCalls_free) {
46194                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46195                 LDKLogger_JCalls_cloned(&logger_conv);
46196         }
46197         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
46198         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
46199         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
46200         unsigned char random_seed_bytes_arr[32];
46201         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
46202         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
46203         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
46204         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
46205         *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);
46206         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
46207         return (int64_t)ret_conv;
46208 }
46209
46210 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) {
46211         LDKPublicKey our_node_pubkey_ref;
46212         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
46213         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
46214         LDKCVec_PublicKeyZ hops_constr;
46215         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
46216         if (hops_constr.datalen > 0)
46217                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
46218         else
46219                 hops_constr.data = NULL;
46220         for (size_t i = 0; i < hops_constr.datalen; i++) {
46221                 int8_tArray hops_conv_8 = (*env)->GetObjectArrayElement(env, hops, i);
46222                 LDKPublicKey hops_conv_8_ref;
46223                 CHECK((*env)->GetArrayLength(env, hops_conv_8) == 33);
46224                 (*env)->GetByteArrayRegion(env, hops_conv_8, 0, 33, hops_conv_8_ref.compressed_form);
46225                 hops_constr.data[i] = hops_conv_8_ref;
46226         }
46227         LDKRouteParameters route_params_conv;
46228         route_params_conv.inner = (void*)(route_params & (~1));
46229         route_params_conv.is_owned = false;
46230         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
46231         LDKNetworkGraph network_graph_conv;
46232         network_graph_conv.inner = (void*)(network_graph & (~1));
46233         network_graph_conv.is_owned = false;
46234         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46235         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
46236         CHECK_ACCESS(logger_ptr);
46237         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46238         if (logger_conv.free == LDKLogger_JCalls_free) {
46239                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46240                 LDKLogger_JCalls_cloned(&logger_conv);
46241         }
46242         unsigned char random_seed_bytes_arr[32];
46243         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
46244         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
46245         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
46246         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
46247         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
46248         return (int64_t)ret_conv;
46249 }
46250
46251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46252         if ((this_ptr & 1) != 0) return;
46253         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
46254         CHECK_ACCESS(this_ptr_ptr);
46255         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
46256         FREE((void*)this_ptr);
46257         Score_free(this_ptr_conv);
46258 }
46259
46260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46261         if ((this_ptr & 1) != 0) return;
46262         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
46263         CHECK_ACCESS(this_ptr_ptr);
46264         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
46265         FREE((void*)this_ptr);
46266         LockableScore_free(this_ptr_conv);
46267 }
46268
46269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46270         LDKMultiThreadedLockableScore this_obj_conv;
46271         this_obj_conv.inner = (void*)(this_obj & (~1));
46272         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46274         MultiThreadedLockableScore_free(this_obj_conv);
46275 }
46276
46277 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
46278         LDKMultiThreadedLockableScore obj_conv;
46279         obj_conv.inner = (void*)(obj & (~1));
46280         obj_conv.is_owned = false;
46281         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46282         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
46283         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46284         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46285         CVec_u8Z_free(ret_var);
46286         return ret_arr;
46287 }
46288
46289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
46290         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
46291         CHECK_ACCESS(score_ptr);
46292         LDKScore score_conv = *(LDKScore*)(score_ptr);
46293         if (score_conv.free == LDKScore_JCalls_free) {
46294                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46295                 LDKScore_JCalls_cloned(&score_conv);
46296         }
46297         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
46298         int64_t ret_ref = 0;
46299         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46300         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46302         ret_ref = (uintptr_t)ret_var.inner;
46303         if (ret_var.is_owned) {
46304                 ret_ref |= 1;
46305         }
46306         return ret_ref;
46307 }
46308
46309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46310         LDKChannelUsage this_obj_conv;
46311         this_obj_conv.inner = (void*)(this_obj & (~1));
46312         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46314         ChannelUsage_free(this_obj_conv);
46315 }
46316
46317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46318         LDKChannelUsage this_ptr_conv;
46319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46320         this_ptr_conv.is_owned = false;
46321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46322         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
46323         return ret_conv;
46324 }
46325
46326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46327         LDKChannelUsage this_ptr_conv;
46328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46329         this_ptr_conv.is_owned = false;
46330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46331         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
46332 }
46333
46334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46335         LDKChannelUsage this_ptr_conv;
46336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46337         this_ptr_conv.is_owned = false;
46338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46339         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
46340         return ret_conv;
46341 }
46342
46343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46344         LDKChannelUsage this_ptr_conv;
46345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46346         this_ptr_conv.is_owned = false;
46347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46348         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
46349 }
46350
46351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr) {
46352         LDKChannelUsage this_ptr_conv;
46353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46354         this_ptr_conv.is_owned = false;
46355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46356         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46357         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
46358         int64_t ret_ref = (uintptr_t)ret_copy;
46359         return ret_ref;
46360 }
46361
46362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46363         LDKChannelUsage this_ptr_conv;
46364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46365         this_ptr_conv.is_owned = false;
46366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46367         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
46368         CHECK_ACCESS(val_ptr);
46369         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
46370         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)val) & ~1));
46371         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
46372 }
46373
46374 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) {
46375         void* effective_capacity_arg_ptr = (void*)(((uintptr_t)effective_capacity_arg) & ~1);
46376         CHECK_ACCESS(effective_capacity_arg_ptr);
46377         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
46378         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)effective_capacity_arg) & ~1));
46379         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
46380         int64_t ret_ref = 0;
46381         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46382         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46384         ret_ref = (uintptr_t)ret_var.inner;
46385         if (ret_var.is_owned) {
46386                 ret_ref |= 1;
46387         }
46388         return ret_ref;
46389 }
46390
46391 static inline uintptr_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
46392         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
46393 int64_t ret_ref = 0;
46394 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46395 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46396 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46397 ret_ref = (uintptr_t)ret_var.inner;
46398 if (ret_var.is_owned) {
46399         ret_ref |= 1;
46400 }
46401         return ret_ref;
46402 }
46403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46404         LDKChannelUsage arg_conv;
46405         arg_conv.inner = (void*)(arg & (~1));
46406         arg_conv.is_owned = false;
46407         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46408         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
46409         return ret_conv;
46410 }
46411
46412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46413         LDKChannelUsage orig_conv;
46414         orig_conv.inner = (void*)(orig & (~1));
46415         orig_conv.is_owned = false;
46416         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46417         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
46418         int64_t ret_ref = 0;
46419         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46420         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46422         ret_ref = (uintptr_t)ret_var.inner;
46423         if (ret_var.is_owned) {
46424                 ret_ref |= 1;
46425         }
46426         return ret_ref;
46427 }
46428
46429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46430         LDKFixedPenaltyScorer this_obj_conv;
46431         this_obj_conv.inner = (void*)(this_obj & (~1));
46432         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46434         FixedPenaltyScorer_free(this_obj_conv);
46435 }
46436
46437 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
46438         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
46439 int64_t ret_ref = 0;
46440 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46441 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46442 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46443 ret_ref = (uintptr_t)ret_var.inner;
46444 if (ret_var.is_owned) {
46445         ret_ref |= 1;
46446 }
46447         return ret_ref;
46448 }
46449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46450         LDKFixedPenaltyScorer arg_conv;
46451         arg_conv.inner = (void*)(arg & (~1));
46452         arg_conv.is_owned = false;
46453         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46454         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
46455         return ret_conv;
46456 }
46457
46458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46459         LDKFixedPenaltyScorer orig_conv;
46460         orig_conv.inner = (void*)(orig & (~1));
46461         orig_conv.is_owned = false;
46462         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46463         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
46464         int64_t ret_ref = 0;
46465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46468         ret_ref = (uintptr_t)ret_var.inner;
46469         if (ret_var.is_owned) {
46470                 ret_ref |= 1;
46471         }
46472         return ret_ref;
46473 }
46474
46475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
46476         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
46477         int64_t ret_ref = 0;
46478         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46479         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46481         ret_ref = (uintptr_t)ret_var.inner;
46482         if (ret_var.is_owned) {
46483                 ret_ref |= 1;
46484         }
46485         return ret_ref;
46486 }
46487
46488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
46489         LDKFixedPenaltyScorer this_arg_conv;
46490         this_arg_conv.inner = (void*)(this_arg & (~1));
46491         this_arg_conv.is_owned = false;
46492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46493         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
46494         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
46495         return (int64_t)ret_ret;
46496 }
46497
46498 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
46499         LDKFixedPenaltyScorer obj_conv;
46500         obj_conv.inner = (void*)(obj & (~1));
46501         obj_conv.is_owned = false;
46502         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46503         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
46504         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46505         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46506         CVec_u8Z_free(ret_var);
46507         return ret_arr;
46508 }
46509
46510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
46511         LDKu8slice ser_ref;
46512         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46513         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46514         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
46515         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
46516         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46517         return (int64_t)ret_conv;
46518 }
46519
46520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46521         LDKProbabilisticScorer this_obj_conv;
46522         this_obj_conv.inner = (void*)(this_obj & (~1));
46523         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46525         ProbabilisticScorer_free(this_obj_conv);
46526 }
46527
46528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46529         LDKProbabilisticScoringParameters this_obj_conv;
46530         this_obj_conv.inner = (void*)(this_obj & (~1));
46531         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46533         ProbabilisticScoringParameters_free(this_obj_conv);
46534 }
46535
46536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46537         LDKProbabilisticScoringParameters this_ptr_conv;
46538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46539         this_ptr_conv.is_owned = false;
46540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46541         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
46542         return ret_conv;
46543 }
46544
46545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46546         LDKProbabilisticScoringParameters this_ptr_conv;
46547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46548         this_ptr_conv.is_owned = false;
46549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46550         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
46551 }
46552
46553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46554         LDKProbabilisticScoringParameters this_ptr_conv;
46555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46556         this_ptr_conv.is_owned = false;
46557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46558         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
46559         return ret_conv;
46560 }
46561
46562 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) {
46563         LDKProbabilisticScoringParameters this_ptr_conv;
46564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46565         this_ptr_conv.is_owned = false;
46566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46567         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
46568 }
46569
46570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46571         LDKProbabilisticScoringParameters this_ptr_conv;
46572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46573         this_ptr_conv.is_owned = false;
46574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46575         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
46576         return ret_conv;
46577 }
46578
46579 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) {
46580         LDKProbabilisticScoringParameters this_ptr_conv;
46581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46582         this_ptr_conv.is_owned = false;
46583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46584         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
46585 }
46586
46587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
46588         LDKProbabilisticScoringParameters this_ptr_conv;
46589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46590         this_ptr_conv.is_owned = false;
46591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46592         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
46593         return ret_conv;
46594 }
46595
46596 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) {
46597         LDKProbabilisticScoringParameters this_ptr_conv;
46598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46599         this_ptr_conv.is_owned = false;
46600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46601         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
46602 }
46603
46604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46605         LDKProbabilisticScoringParameters this_ptr_conv;
46606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46607         this_ptr_conv.is_owned = false;
46608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46609         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
46610         return ret_conv;
46611 }
46612
46613 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) {
46614         LDKProbabilisticScoringParameters this_ptr_conv;
46615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46616         this_ptr_conv.is_owned = false;
46617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46618         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
46619 }
46620
46621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46622         LDKProbabilisticScoringParameters this_ptr_conv;
46623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46624         this_ptr_conv.is_owned = false;
46625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46626         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
46627         return ret_conv;
46628 }
46629
46630 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) {
46631         LDKProbabilisticScoringParameters this_ptr_conv;
46632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46633         this_ptr_conv.is_owned = false;
46634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46635         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
46636 }
46637
46638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46639         LDKProbabilisticScoringParameters this_ptr_conv;
46640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46641         this_ptr_conv.is_owned = false;
46642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46643         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
46644         return ret_conv;
46645 }
46646
46647 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) {
46648         LDKProbabilisticScoringParameters this_ptr_conv;
46649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46650         this_ptr_conv.is_owned = false;
46651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46652         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
46653 }
46654
46655 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
46656         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
46657 int64_t ret_ref = 0;
46658 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46659 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46660 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46661 ret_ref = (uintptr_t)ret_var.inner;
46662 if (ret_var.is_owned) {
46663         ret_ref |= 1;
46664 }
46665         return ret_ref;
46666 }
46667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46668         LDKProbabilisticScoringParameters arg_conv;
46669         arg_conv.inner = (void*)(arg & (~1));
46670         arg_conv.is_owned = false;
46671         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46672         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
46673         return ret_conv;
46674 }
46675
46676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46677         LDKProbabilisticScoringParameters orig_conv;
46678         orig_conv.inner = (void*)(orig & (~1));
46679         orig_conv.is_owned = false;
46680         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46681         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
46682         int64_t ret_ref = 0;
46683         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46684         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46686         ret_ref = (uintptr_t)ret_var.inner;
46687         if (ret_var.is_owned) {
46688                 ret_ref |= 1;
46689         }
46690         return ret_ref;
46691 }
46692
46693 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) {
46694         LDKProbabilisticScoringParameters params_conv;
46695         params_conv.inner = (void*)(params & (~1));
46696         params_conv.is_owned = (params & 1) || (params == 0);
46697         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
46698         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
46699         LDKNetworkGraph network_graph_conv;
46700         network_graph_conv.inner = (void*)(network_graph & (~1));
46701         network_graph_conv.is_owned = false;
46702         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46703         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
46704         CHECK_ACCESS(logger_ptr);
46705         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46706         if (logger_conv.free == LDKLogger_JCalls_free) {
46707                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46708                 LDKLogger_JCalls_cloned(&logger_conv);
46709         }
46710         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
46711         int64_t ret_ref = 0;
46712         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46713         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46715         ret_ref = (uintptr_t)ret_var.inner;
46716         if (ret_var.is_owned) {
46717                 ret_ref |= 1;
46718         }
46719         return ret_ref;
46720 }
46721
46722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1debug_1log_1liquidity_1stats(JNIEnv *env, jclass clz, int64_t this_arg) {
46723         LDKProbabilisticScorer this_arg_conv;
46724         this_arg_conv.inner = (void*)(this_arg & (~1));
46725         this_arg_conv.is_owned = false;
46726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46727         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
46728 }
46729
46730 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) {
46731         LDKProbabilisticScorer this_arg_conv;
46732         this_arg_conv.inner = (void*)(this_arg & (~1));
46733         this_arg_conv.is_owned = false;
46734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46735         LDKNodeId target_conv;
46736         target_conv.inner = (void*)(target & (~1));
46737         target_conv.is_owned = false;
46738         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
46739         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
46740         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
46741         int64_t ret_ref = (uintptr_t)ret_copy;
46742         return ret_ref;
46743 }
46744
46745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1add_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
46746         LDKProbabilisticScorer this_arg_conv;
46747         this_arg_conv.inner = (void*)(this_arg & (~1));
46748         this_arg_conv.is_owned = false;
46749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46750         LDKNodeId node_id_conv;
46751         node_id_conv.inner = (void*)(node_id & (~1));
46752         node_id_conv.is_owned = false;
46753         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
46754         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
46755 }
46756
46757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
46758         LDKProbabilisticScorer this_arg_conv;
46759         this_arg_conv.inner = (void*)(this_arg & (~1));
46760         this_arg_conv.is_owned = false;
46761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46762         LDKNodeId node_id_conv;
46763         node_id_conv.inner = (void*)(node_id & (~1));
46764         node_id_conv.is_owned = false;
46765         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
46766         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
46767 }
46768
46769 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) {
46770         LDKProbabilisticScorer this_arg_conv;
46771         this_arg_conv.inner = (void*)(this_arg & (~1));
46772         this_arg_conv.is_owned = false;
46773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46774         LDKNodeId node_id_conv;
46775         node_id_conv.inner = (void*)(node_id & (~1));
46776         node_id_conv.is_owned = false;
46777         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
46778         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
46779 }
46780
46781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
46782         LDKProbabilisticScorer this_arg_conv;
46783         this_arg_conv.inner = (void*)(this_arg & (~1));
46784         this_arg_conv.is_owned = false;
46785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46786         LDKNodeId node_id_conv;
46787         node_id_conv.inner = (void*)(node_id & (~1));
46788         node_id_conv.is_owned = false;
46789         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
46790         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
46791 }
46792
46793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1clear_1manual_1penalties(JNIEnv *env, jclass clz, int64_t this_arg) {
46794         LDKProbabilisticScorer this_arg_conv;
46795         this_arg_conv.inner = (void*)(this_arg & (~1));
46796         this_arg_conv.is_owned = false;
46797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46798         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
46799 }
46800
46801 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) {
46802         LDKProbabilisticScoringParameters this_arg_conv;
46803         this_arg_conv.inner = (void*)(this_arg & (~1));
46804         this_arg_conv.is_owned = false;
46805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46806         LDKCVec_NodeIdZ node_ids_constr;
46807         node_ids_constr.datalen = (*env)->GetArrayLength(env, node_ids);
46808         if (node_ids_constr.datalen > 0)
46809                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
46810         else
46811                 node_ids_constr.data = NULL;
46812         int64_t* node_ids_vals = (*env)->GetLongArrayElements (env, node_ids, NULL);
46813         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
46814                 int64_t node_ids_conv_8 = node_ids_vals[i];
46815                 LDKNodeId node_ids_conv_8_conv;
46816                 node_ids_conv_8_conv.inner = (void*)(node_ids_conv_8 & (~1));
46817                 node_ids_conv_8_conv.is_owned = (node_ids_conv_8 & 1) || (node_ids_conv_8 == 0);
46818                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
46819                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
46820                 node_ids_constr.data[i] = node_ids_conv_8_conv;
46821         }
46822         (*env)->ReleaseLongArrayElements(env, node_ids, node_ids_vals, 0);
46823         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
46824 }
46825
46826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
46827         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
46828         int64_t ret_ref = 0;
46829         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46830         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46832         ret_ref = (uintptr_t)ret_var.inner;
46833         if (ret_var.is_owned) {
46834                 ret_ref |= 1;
46835         }
46836         return ret_ref;
46837 }
46838
46839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
46840         LDKProbabilisticScorer this_arg_conv;
46841         this_arg_conv.inner = (void*)(this_arg & (~1));
46842         this_arg_conv.is_owned = false;
46843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46844         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
46845         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
46846         return (int64_t)ret_ret;
46847 }
46848
46849 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
46850         LDKProbabilisticScorer obj_conv;
46851         obj_conv.inner = (void*)(obj & (~1));
46852         obj_conv.is_owned = false;
46853         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46854         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
46855         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46856         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46857         CVec_u8Z_free(ret_var);
46858         return ret_arr;
46859 }
46860
46861 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) {
46862         LDKu8slice ser_ref;
46863         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46864         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46865         LDKProbabilisticScoringParameters arg_a_conv;
46866         arg_a_conv.inner = (void*)(arg_a & (~1));
46867         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
46868         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
46869         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
46870         LDKNetworkGraph arg_b_conv;
46871         arg_b_conv.inner = (void*)(arg_b & (~1));
46872         arg_b_conv.is_owned = false;
46873         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
46874         void* arg_c_ptr = (void*)(((uintptr_t)arg_c) & ~1);
46875         CHECK_ACCESS(arg_c_ptr);
46876         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
46877         if (arg_c_conv.free == LDKLogger_JCalls_free) {
46878                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46879                 LDKLogger_JCalls_cloned(&arg_c_conv);
46880         }
46881         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
46882         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
46883         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46884         return (int64_t)ret_conv;
46885 }
46886
46887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46888         LDKFilesystemPersister this_obj_conv;
46889         this_obj_conv.inner = (void*)(this_obj & (~1));
46890         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46892         FilesystemPersister_free(this_obj_conv);
46893 }
46894
46895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
46896         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
46897         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
46898         int64_t ret_ref = 0;
46899         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46900         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46902         ret_ref = (uintptr_t)ret_var.inner;
46903         if (ret_var.is_owned) {
46904                 ret_ref |= 1;
46905         }
46906         return ret_ref;
46907 }
46908
46909 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
46910         LDKFilesystemPersister this_arg_conv;
46911         this_arg_conv.inner = (void*)(this_arg & (~1));
46912         this_arg_conv.is_owned = false;
46913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46914         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
46915         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46916         Str_free(ret_str);
46917         return ret_conv;
46918 }
46919
46920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
46921         LDKFilesystemPersister this_arg_conv;
46922         this_arg_conv.inner = (void*)(this_arg & (~1));
46923         this_arg_conv.is_owned = false;
46924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46925         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46926         CHECK_ACCESS(keys_manager_ptr);
46927         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46928         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46929                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46930                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46931         }
46932         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
46933         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
46934         return (int64_t)ret_conv;
46935 }
46936
46937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46938         LDKBackgroundProcessor this_obj_conv;
46939         this_obj_conv.inner = (void*)(this_obj & (~1));
46940         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46942         BackgroundProcessor_free(this_obj_conv);
46943 }
46944
46945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipSync_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46946         if ((this_ptr & 1) != 0) return;
46947         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
46948         CHECK_ACCESS(this_ptr_ptr);
46949         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
46950         FREE((void*)this_ptr);
46951         GossipSync_free(this_ptr_conv);
46952 }
46953
46954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1p2_1p(JNIEnv *env, jclass clz, int64_t a) {
46955         LDKP2PGossipSync a_conv;
46956         a_conv.inner = (void*)(a & (~1));
46957         a_conv.is_owned = false;
46958         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46959         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
46960         *ret_copy = GossipSync_p2_p(&a_conv);
46961         int64_t ret_ref = (uintptr_t)ret_copy;
46962         return ret_ref;
46963 }
46964
46965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1rapid(JNIEnv *env, jclass clz, int64_t a) {
46966         LDKRapidGossipSync a_conv;
46967         a_conv.inner = (void*)(a & (~1));
46968         a_conv.is_owned = false;
46969         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46970         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
46971         *ret_copy = GossipSync_rapid(&a_conv);
46972         int64_t ret_ref = (uintptr_t)ret_copy;
46973         return ret_ref;
46974 }
46975
46976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1none(JNIEnv *env, jclass clz) {
46977         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
46978         *ret_copy = GossipSync_none();
46979         int64_t ret_ref = (uintptr_t)ret_copy;
46980         return ret_ref;
46981 }
46982
46983 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) {
46984         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
46985         CHECK_ACCESS(persister_ptr);
46986         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
46987         if (persister_conv.free == LDKPersister_JCalls_free) {
46988                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46989                 LDKPersister_JCalls_cloned(&persister_conv);
46990         }
46991         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
46992         CHECK_ACCESS(event_handler_ptr);
46993         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
46994         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
46995                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46996                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
46997         }
46998         LDKChainMonitor chain_monitor_conv;
46999         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
47000         chain_monitor_conv.is_owned = false;
47001         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
47002         LDKChannelManager channel_manager_conv;
47003         channel_manager_conv.inner = (void*)(channel_manager & (~1));
47004         channel_manager_conv.is_owned = false;
47005         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
47006         void* gossip_sync_ptr = (void*)(((uintptr_t)gossip_sync) & ~1);
47007         CHECK_ACCESS(gossip_sync_ptr);
47008         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
47009         // WARNING: we may need a move here but no clone is available for LDKGossipSync
47010         LDKPeerManager peer_manager_conv;
47011         peer_manager_conv.inner = (void*)(peer_manager & (~1));
47012         peer_manager_conv.is_owned = false;
47013         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
47014         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
47015         CHECK_ACCESS(logger_ptr);
47016         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47017         if (logger_conv.free == LDKLogger_JCalls_free) {
47018                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47019                 LDKLogger_JCalls_cloned(&logger_conv);
47020         }
47021         LDKMultiThreadedLockableScore scorer_conv;
47022         scorer_conv.inner = (void*)(scorer & (~1));
47023         scorer_conv.is_owned = (scorer & 1) || (scorer == 0);
47024         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
47025         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);
47026         int64_t ret_ref = 0;
47027         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47028         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47030         ret_ref = (uintptr_t)ret_var.inner;
47031         if (ret_var.is_owned) {
47032                 ret_ref |= 1;
47033         }
47034         return ret_ref;
47035 }
47036
47037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
47038         LDKBackgroundProcessor this_arg_conv;
47039         this_arg_conv.inner = (void*)(this_arg & (~1));
47040         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
47041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47042         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
47043         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
47044         *ret_conv = BackgroundProcessor_join(this_arg_conv);
47045         return (int64_t)ret_conv;
47046 }
47047
47048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
47049         LDKBackgroundProcessor this_arg_conv;
47050         this_arg_conv.inner = (void*)(this_arg & (~1));
47051         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
47052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47053         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
47054         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
47055         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
47056         return (int64_t)ret_conv;
47057 }
47058
47059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47060         if ((this_ptr & 1) != 0) return;
47061         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
47062         CHECK_ACCESS(this_ptr_ptr);
47063         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
47064         FREE((void*)this_ptr);
47065         ParseError_free(this_ptr_conv);
47066 }
47067
47068 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
47069         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47070         *ret_copy = ParseError_clone(arg);
47071 int64_t ret_ref = (uintptr_t)ret_copy;
47072         return ret_ref;
47073 }
47074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47075         LDKParseError* arg_conv = (LDKParseError*)arg;
47076         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
47077         return ret_conv;
47078 }
47079
47080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47081         LDKParseError* orig_conv = (LDKParseError*)orig;
47082         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47083         *ret_copy = ParseError_clone(orig_conv);
47084         int64_t ret_ref = (uintptr_t)ret_copy;
47085         return ret_ref;
47086 }
47087
47088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
47089         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
47090         CHECK_ACCESS(a_ptr);
47091         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
47092         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
47093         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47094         *ret_copy = ParseError_bech32_error(a_conv);
47095         int64_t ret_ref = (uintptr_t)ret_copy;
47096         return ret_ref;
47097 }
47098
47099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
47100         
47101         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47102         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
47103         int64_t ret_ref = (uintptr_t)ret_copy;
47104         return ret_ref;
47105 }
47106
47107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
47108         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
47109         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47110         *ret_copy = ParseError_malformed_signature(a_conv);
47111         int64_t ret_ref = (uintptr_t)ret_copy;
47112         return ret_ref;
47113 }
47114
47115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
47116         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47117         *ret_copy = ParseError_bad_prefix();
47118         int64_t ret_ref = (uintptr_t)ret_copy;
47119         return ret_ref;
47120 }
47121
47122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
47123         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47124         *ret_copy = ParseError_unknown_currency();
47125         int64_t ret_ref = (uintptr_t)ret_copy;
47126         return ret_ref;
47127 }
47128
47129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
47130         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47131         *ret_copy = ParseError_unknown_si_prefix();
47132         int64_t ret_ref = (uintptr_t)ret_copy;
47133         return ret_ref;
47134 }
47135
47136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
47137         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47138         *ret_copy = ParseError_malformed_hrp();
47139         int64_t ret_ref = (uintptr_t)ret_copy;
47140         return ret_ref;
47141 }
47142
47143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
47144         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47145         *ret_copy = ParseError_too_short_data_part();
47146         int64_t ret_ref = (uintptr_t)ret_copy;
47147         return ret_ref;
47148 }
47149
47150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
47151         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47152         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
47153         int64_t ret_ref = (uintptr_t)ret_copy;
47154         return ret_ref;
47155 }
47156
47157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
47158         
47159         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47160         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
47161         int64_t ret_ref = (uintptr_t)ret_copy;
47162         return ret_ref;
47163 }
47164
47165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
47166         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47167         *ret_copy = ParseError_padding_error();
47168         int64_t ret_ref = (uintptr_t)ret_copy;
47169         return ret_ref;
47170 }
47171
47172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
47173         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47174         *ret_copy = ParseError_integer_overflow_error();
47175         int64_t ret_ref = (uintptr_t)ret_copy;
47176         return ret_ref;
47177 }
47178
47179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
47180         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47181         *ret_copy = ParseError_invalid_seg_wit_program_length();
47182         int64_t ret_ref = (uintptr_t)ret_copy;
47183         return ret_ref;
47184 }
47185
47186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
47187         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47188         *ret_copy = ParseError_invalid_pub_key_hash_length();
47189         int64_t ret_ref = (uintptr_t)ret_copy;
47190         return ret_ref;
47191 }
47192
47193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
47194         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47195         *ret_copy = ParseError_invalid_script_hash_length();
47196         int64_t ret_ref = (uintptr_t)ret_copy;
47197         return ret_ref;
47198 }
47199
47200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
47201         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47202         *ret_copy = ParseError_invalid_recovery_id();
47203         int64_t ret_ref = (uintptr_t)ret_copy;
47204         return ret_ref;
47205 }
47206
47207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
47208         LDKStr a_conv = java_to_owned_str(env, a);
47209         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47210         *ret_copy = ParseError_invalid_slice_length(a_conv);
47211         int64_t ret_ref = (uintptr_t)ret_copy;
47212         return ret_ref;
47213 }
47214
47215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
47216         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47217         *ret_copy = ParseError_skip();
47218         int64_t ret_ref = (uintptr_t)ret_copy;
47219         return ret_ref;
47220 }
47221
47222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47223         if ((this_ptr & 1) != 0) return;
47224         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
47225         CHECK_ACCESS(this_ptr_ptr);
47226         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
47227         FREE((void*)this_ptr);
47228         ParseOrSemanticError_free(this_ptr_conv);
47229 }
47230
47231 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
47232         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
47233         *ret_copy = ParseOrSemanticError_clone(arg);
47234 int64_t ret_ref = (uintptr_t)ret_copy;
47235         return ret_ref;
47236 }
47237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47238         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
47239         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
47240         return ret_conv;
47241 }
47242
47243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47244         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
47245         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
47246         *ret_copy = ParseOrSemanticError_clone(orig_conv);
47247         int64_t ret_ref = (uintptr_t)ret_copy;
47248         return ret_ref;
47249 }
47250
47251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
47252         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
47253         CHECK_ACCESS(a_ptr);
47254         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
47255         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
47256         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
47257         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
47258         int64_t ret_ref = (uintptr_t)ret_copy;
47259         return ret_ref;
47260 }
47261
47262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
47263         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
47264         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
47265         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
47266         int64_t ret_ref = (uintptr_t)ret_copy;
47267         return ret_ref;
47268 }
47269
47270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47271         LDKInvoice this_obj_conv;
47272         this_obj_conv.inner = (void*)(this_obj & (~1));
47273         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47275         Invoice_free(this_obj_conv);
47276 }
47277
47278 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47279         LDKInvoice a_conv;
47280         a_conv.inner = (void*)(a & (~1));
47281         a_conv.is_owned = false;
47282         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47283         LDKInvoice b_conv;
47284         b_conv.inner = (void*)(b & (~1));
47285         b_conv.is_owned = false;
47286         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47287         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
47288         return ret_conv;
47289 }
47290
47291 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
47292         LDKInvoice ret_var = Invoice_clone(arg);
47293 int64_t ret_ref = 0;
47294 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47295 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47296 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47297 ret_ref = (uintptr_t)ret_var.inner;
47298 if (ret_var.is_owned) {
47299         ret_ref |= 1;
47300 }
47301         return ret_ref;
47302 }
47303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47304         LDKInvoice arg_conv;
47305         arg_conv.inner = (void*)(arg & (~1));
47306         arg_conv.is_owned = false;
47307         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47308         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
47309         return ret_conv;
47310 }
47311
47312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47313         LDKInvoice orig_conv;
47314         orig_conv.inner = (void*)(orig & (~1));
47315         orig_conv.is_owned = false;
47316         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47317         LDKInvoice ret_var = Invoice_clone(&orig_conv);
47318         int64_t ret_ref = 0;
47319         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47320         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47322         ret_ref = (uintptr_t)ret_var.inner;
47323         if (ret_var.is_owned) {
47324                 ret_ref |= 1;
47325         }
47326         return ret_ref;
47327 }
47328
47329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47330         LDKSignedRawInvoice this_obj_conv;
47331         this_obj_conv.inner = (void*)(this_obj & (~1));
47332         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47334         SignedRawInvoice_free(this_obj_conv);
47335 }
47336
47337 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47338         LDKSignedRawInvoice a_conv;
47339         a_conv.inner = (void*)(a & (~1));
47340         a_conv.is_owned = false;
47341         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47342         LDKSignedRawInvoice b_conv;
47343         b_conv.inner = (void*)(b & (~1));
47344         b_conv.is_owned = false;
47345         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47346         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
47347         return ret_conv;
47348 }
47349
47350 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
47351         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
47352 int64_t ret_ref = 0;
47353 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47354 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47355 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47356 ret_ref = (uintptr_t)ret_var.inner;
47357 if (ret_var.is_owned) {
47358         ret_ref |= 1;
47359 }
47360         return ret_ref;
47361 }
47362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47363         LDKSignedRawInvoice arg_conv;
47364         arg_conv.inner = (void*)(arg & (~1));
47365         arg_conv.is_owned = false;
47366         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47367         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
47368         return ret_conv;
47369 }
47370
47371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47372         LDKSignedRawInvoice orig_conv;
47373         orig_conv.inner = (void*)(orig & (~1));
47374         orig_conv.is_owned = false;
47375         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47376         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
47377         int64_t ret_ref = 0;
47378         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47379         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47381         ret_ref = (uintptr_t)ret_var.inner;
47382         if (ret_var.is_owned) {
47383                 ret_ref |= 1;
47384         }
47385         return ret_ref;
47386 }
47387
47388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47389         LDKRawInvoice this_obj_conv;
47390         this_obj_conv.inner = (void*)(this_obj & (~1));
47391         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47393         RawInvoice_free(this_obj_conv);
47394 }
47395
47396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
47397         LDKRawInvoice this_ptr_conv;
47398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47399         this_ptr_conv.is_owned = false;
47400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47401         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
47402         int64_t ret_ref = 0;
47403         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47404         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47406         ret_ref = (uintptr_t)ret_var.inner;
47407         if (ret_var.is_owned) {
47408                 ret_ref |= 1;
47409         }
47410         return ret_ref;
47411 }
47412
47413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47414         LDKRawInvoice this_ptr_conv;
47415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47416         this_ptr_conv.is_owned = false;
47417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47418         LDKRawDataPart val_conv;
47419         val_conv.inner = (void*)(val & (~1));
47420         val_conv.is_owned = (val & 1) || (val == 0);
47421         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47422         val_conv = RawDataPart_clone(&val_conv);
47423         RawInvoice_set_data(&this_ptr_conv, val_conv);
47424 }
47425
47426 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47427         LDKRawInvoice a_conv;
47428         a_conv.inner = (void*)(a & (~1));
47429         a_conv.is_owned = false;
47430         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47431         LDKRawInvoice b_conv;
47432         b_conv.inner = (void*)(b & (~1));
47433         b_conv.is_owned = false;
47434         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47435         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
47436         return ret_conv;
47437 }
47438
47439 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
47440         LDKRawInvoice ret_var = RawInvoice_clone(arg);
47441 int64_t ret_ref = 0;
47442 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47443 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47444 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47445 ret_ref = (uintptr_t)ret_var.inner;
47446 if (ret_var.is_owned) {
47447         ret_ref |= 1;
47448 }
47449         return ret_ref;
47450 }
47451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47452         LDKRawInvoice arg_conv;
47453         arg_conv.inner = (void*)(arg & (~1));
47454         arg_conv.is_owned = false;
47455         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47456         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
47457         return ret_conv;
47458 }
47459
47460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47461         LDKRawInvoice orig_conv;
47462         orig_conv.inner = (void*)(orig & (~1));
47463         orig_conv.is_owned = false;
47464         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47465         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
47466         int64_t ret_ref = 0;
47467         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47468         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47470         ret_ref = (uintptr_t)ret_var.inner;
47471         if (ret_var.is_owned) {
47472                 ret_ref |= 1;
47473         }
47474         return ret_ref;
47475 }
47476
47477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47478         LDKRawDataPart this_obj_conv;
47479         this_obj_conv.inner = (void*)(this_obj & (~1));
47480         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47482         RawDataPart_free(this_obj_conv);
47483 }
47484
47485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
47486         LDKRawDataPart this_ptr_conv;
47487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47488         this_ptr_conv.is_owned = false;
47489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47490         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
47491         int64_t ret_ref = 0;
47492         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47493         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47495         ret_ref = (uintptr_t)ret_var.inner;
47496         if (ret_var.is_owned) {
47497                 ret_ref |= 1;
47498         }
47499         return ret_ref;
47500 }
47501
47502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47503         LDKRawDataPart this_ptr_conv;
47504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47505         this_ptr_conv.is_owned = false;
47506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47507         LDKPositiveTimestamp val_conv;
47508         val_conv.inner = (void*)(val & (~1));
47509         val_conv.is_owned = (val & 1) || (val == 0);
47510         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47511         val_conv = PositiveTimestamp_clone(&val_conv);
47512         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
47513 }
47514
47515 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47516         LDKRawDataPart a_conv;
47517         a_conv.inner = (void*)(a & (~1));
47518         a_conv.is_owned = false;
47519         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47520         LDKRawDataPart b_conv;
47521         b_conv.inner = (void*)(b & (~1));
47522         b_conv.is_owned = false;
47523         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47524         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
47525         return ret_conv;
47526 }
47527
47528 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
47529         LDKRawDataPart ret_var = RawDataPart_clone(arg);
47530 int64_t ret_ref = 0;
47531 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47532 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47533 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47534 ret_ref = (uintptr_t)ret_var.inner;
47535 if (ret_var.is_owned) {
47536         ret_ref |= 1;
47537 }
47538         return ret_ref;
47539 }
47540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47541         LDKRawDataPart arg_conv;
47542         arg_conv.inner = (void*)(arg & (~1));
47543         arg_conv.is_owned = false;
47544         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47545         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
47546         return ret_conv;
47547 }
47548
47549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47550         LDKRawDataPart orig_conv;
47551         orig_conv.inner = (void*)(orig & (~1));
47552         orig_conv.is_owned = false;
47553         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47554         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
47555         int64_t ret_ref = 0;
47556         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47557         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47559         ret_ref = (uintptr_t)ret_var.inner;
47560         if (ret_var.is_owned) {
47561                 ret_ref |= 1;
47562         }
47563         return ret_ref;
47564 }
47565
47566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47567         LDKPositiveTimestamp this_obj_conv;
47568         this_obj_conv.inner = (void*)(this_obj & (~1));
47569         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47571         PositiveTimestamp_free(this_obj_conv);
47572 }
47573
47574 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47575         LDKPositiveTimestamp a_conv;
47576         a_conv.inner = (void*)(a & (~1));
47577         a_conv.is_owned = false;
47578         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47579         LDKPositiveTimestamp b_conv;
47580         b_conv.inner = (void*)(b & (~1));
47581         b_conv.is_owned = false;
47582         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47583         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
47584         return ret_conv;
47585 }
47586
47587 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
47588         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
47589 int64_t ret_ref = 0;
47590 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47591 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47592 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47593 ret_ref = (uintptr_t)ret_var.inner;
47594 if (ret_var.is_owned) {
47595         ret_ref |= 1;
47596 }
47597         return ret_ref;
47598 }
47599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47600         LDKPositiveTimestamp arg_conv;
47601         arg_conv.inner = (void*)(arg & (~1));
47602         arg_conv.is_owned = false;
47603         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47604         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
47605         return ret_conv;
47606 }
47607
47608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47609         LDKPositiveTimestamp orig_conv;
47610         orig_conv.inner = (void*)(orig & (~1));
47611         orig_conv.is_owned = false;
47612         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47613         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
47614         int64_t ret_ref = 0;
47615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47618         ret_ref = (uintptr_t)ret_var.inner;
47619         if (ret_var.is_owned) {
47620                 ret_ref |= 1;
47621         }
47622         return ret_ref;
47623 }
47624
47625 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47626         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
47627         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
47628         return ret_conv;
47629 }
47630
47631 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
47632         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
47633         return ret_conv;
47634 }
47635
47636 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
47637         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
47638         return ret_conv;
47639 }
47640
47641 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
47642         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
47643         return ret_conv;
47644 }
47645
47646 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
47647         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
47648         return ret_conv;
47649 }
47650
47651 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47652         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
47653         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
47654         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
47655         return ret_conv;
47656 }
47657
47658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
47659         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
47660         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
47661         return ret_conv;
47662 }
47663
47664 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47665         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
47666         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
47667         return ret_conv;
47668 }
47669
47670 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
47671         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
47672         return ret_conv;
47673 }
47674
47675 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
47676         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
47677         return ret_conv;
47678 }
47679
47680 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
47681         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
47682         return ret_conv;
47683 }
47684
47685 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
47686         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
47687         return ret_conv;
47688 }
47689
47690 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
47691         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
47692         return ret_conv;
47693 }
47694
47695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
47696         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
47697         int64_t ret_conv = Currency_hash(o_conv);
47698         return ret_conv;
47699 }
47700
47701 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47702         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
47703         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
47704         jboolean ret_conv = Currency_eq(a_conv, b_conv);
47705         return ret_conv;
47706 }
47707
47708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47709         LDKSha256 this_obj_conv;
47710         this_obj_conv.inner = (void*)(this_obj & (~1));
47711         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47713         Sha256_free(this_obj_conv);
47714 }
47715
47716 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
47717         LDKSha256 ret_var = Sha256_clone(arg);
47718 int64_t ret_ref = 0;
47719 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47720 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47721 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47722 ret_ref = (uintptr_t)ret_var.inner;
47723 if (ret_var.is_owned) {
47724         ret_ref |= 1;
47725 }
47726         return ret_ref;
47727 }
47728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47729         LDKSha256 arg_conv;
47730         arg_conv.inner = (void*)(arg & (~1));
47731         arg_conv.is_owned = false;
47732         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47733         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
47734         return ret_conv;
47735 }
47736
47737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47738         LDKSha256 orig_conv;
47739         orig_conv.inner = (void*)(orig & (~1));
47740         orig_conv.is_owned = false;
47741         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47742         LDKSha256 ret_var = Sha256_clone(&orig_conv);
47743         int64_t ret_ref = 0;
47744         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47745         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47747         ret_ref = (uintptr_t)ret_var.inner;
47748         if (ret_var.is_owned) {
47749                 ret_ref |= 1;
47750         }
47751         return ret_ref;
47752 }
47753
47754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
47755         LDKSha256 o_conv;
47756         o_conv.inner = (void*)(o & (~1));
47757         o_conv.is_owned = false;
47758         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47759         int64_t ret_conv = Sha256_hash(&o_conv);
47760         return ret_conv;
47761 }
47762
47763 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47764         LDKSha256 a_conv;
47765         a_conv.inner = (void*)(a & (~1));
47766         a_conv.is_owned = false;
47767         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47768         LDKSha256 b_conv;
47769         b_conv.inner = (void*)(b & (~1));
47770         b_conv.is_owned = false;
47771         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47772         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
47773         return ret_conv;
47774 }
47775
47776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47777         LDKDescription this_obj_conv;
47778         this_obj_conv.inner = (void*)(this_obj & (~1));
47779         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47781         Description_free(this_obj_conv);
47782 }
47783
47784 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
47785         LDKDescription ret_var = Description_clone(arg);
47786 int64_t ret_ref = 0;
47787 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47788 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47789 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47790 ret_ref = (uintptr_t)ret_var.inner;
47791 if (ret_var.is_owned) {
47792         ret_ref |= 1;
47793 }
47794         return ret_ref;
47795 }
47796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47797         LDKDescription arg_conv;
47798         arg_conv.inner = (void*)(arg & (~1));
47799         arg_conv.is_owned = false;
47800         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47801         int64_t ret_conv = Description_clone_ptr(&arg_conv);
47802         return ret_conv;
47803 }
47804
47805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47806         LDKDescription orig_conv;
47807         orig_conv.inner = (void*)(orig & (~1));
47808         orig_conv.is_owned = false;
47809         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47810         LDKDescription ret_var = Description_clone(&orig_conv);
47811         int64_t ret_ref = 0;
47812         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47813         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47814         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47815         ret_ref = (uintptr_t)ret_var.inner;
47816         if (ret_var.is_owned) {
47817                 ret_ref |= 1;
47818         }
47819         return ret_ref;
47820 }
47821
47822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
47823         LDKDescription o_conv;
47824         o_conv.inner = (void*)(o & (~1));
47825         o_conv.is_owned = false;
47826         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47827         int64_t ret_conv = Description_hash(&o_conv);
47828         return ret_conv;
47829 }
47830
47831 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47832         LDKDescription a_conv;
47833         a_conv.inner = (void*)(a & (~1));
47834         a_conv.is_owned = false;
47835         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47836         LDKDescription b_conv;
47837         b_conv.inner = (void*)(b & (~1));
47838         b_conv.is_owned = false;
47839         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47840         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
47841         return ret_conv;
47842 }
47843
47844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47845         LDKPayeePubKey this_obj_conv;
47846         this_obj_conv.inner = (void*)(this_obj & (~1));
47847         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47849         PayeePubKey_free(this_obj_conv);
47850 }
47851
47852 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
47853         LDKPayeePubKey this_ptr_conv;
47854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47855         this_ptr_conv.is_owned = false;
47856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47857         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47858         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
47859         return ret_arr;
47860 }
47861
47862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
47863         LDKPayeePubKey this_ptr_conv;
47864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47865         this_ptr_conv.is_owned = false;
47866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47867         LDKPublicKey val_ref;
47868         CHECK((*env)->GetArrayLength(env, val) == 33);
47869         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
47870         PayeePubKey_set_a(&this_ptr_conv, val_ref);
47871 }
47872
47873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
47874         LDKPublicKey a_arg_ref;
47875         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
47876         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
47877         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
47878         int64_t ret_ref = 0;
47879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47882         ret_ref = (uintptr_t)ret_var.inner;
47883         if (ret_var.is_owned) {
47884                 ret_ref |= 1;
47885         }
47886         return ret_ref;
47887 }
47888
47889 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
47890         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
47891 int64_t ret_ref = 0;
47892 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47893 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47894 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47895 ret_ref = (uintptr_t)ret_var.inner;
47896 if (ret_var.is_owned) {
47897         ret_ref |= 1;
47898 }
47899         return ret_ref;
47900 }
47901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47902         LDKPayeePubKey arg_conv;
47903         arg_conv.inner = (void*)(arg & (~1));
47904         arg_conv.is_owned = false;
47905         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47906         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
47907         return ret_conv;
47908 }
47909
47910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47911         LDKPayeePubKey orig_conv;
47912         orig_conv.inner = (void*)(orig & (~1));
47913         orig_conv.is_owned = false;
47914         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47915         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
47916         int64_t ret_ref = 0;
47917         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47918         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47919         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47920         ret_ref = (uintptr_t)ret_var.inner;
47921         if (ret_var.is_owned) {
47922                 ret_ref |= 1;
47923         }
47924         return ret_ref;
47925 }
47926
47927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
47928         LDKPayeePubKey o_conv;
47929         o_conv.inner = (void*)(o & (~1));
47930         o_conv.is_owned = false;
47931         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47932         int64_t ret_conv = PayeePubKey_hash(&o_conv);
47933         return ret_conv;
47934 }
47935
47936 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47937         LDKPayeePubKey a_conv;
47938         a_conv.inner = (void*)(a & (~1));
47939         a_conv.is_owned = false;
47940         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47941         LDKPayeePubKey b_conv;
47942         b_conv.inner = (void*)(b & (~1));
47943         b_conv.is_owned = false;
47944         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47945         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
47946         return ret_conv;
47947 }
47948
47949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47950         LDKExpiryTime this_obj_conv;
47951         this_obj_conv.inner = (void*)(this_obj & (~1));
47952         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47954         ExpiryTime_free(this_obj_conv);
47955 }
47956
47957 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
47958         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
47959 int64_t ret_ref = 0;
47960 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47961 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47962 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47963 ret_ref = (uintptr_t)ret_var.inner;
47964 if (ret_var.is_owned) {
47965         ret_ref |= 1;
47966 }
47967         return ret_ref;
47968 }
47969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47970         LDKExpiryTime arg_conv;
47971         arg_conv.inner = (void*)(arg & (~1));
47972         arg_conv.is_owned = false;
47973         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47974         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
47975         return ret_conv;
47976 }
47977
47978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47979         LDKExpiryTime orig_conv;
47980         orig_conv.inner = (void*)(orig & (~1));
47981         orig_conv.is_owned = false;
47982         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47983         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
47984         int64_t ret_ref = 0;
47985         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47986         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47988         ret_ref = (uintptr_t)ret_var.inner;
47989         if (ret_var.is_owned) {
47990                 ret_ref |= 1;
47991         }
47992         return ret_ref;
47993 }
47994
47995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
47996         LDKExpiryTime o_conv;
47997         o_conv.inner = (void*)(o & (~1));
47998         o_conv.is_owned = false;
47999         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48000         int64_t ret_conv = ExpiryTime_hash(&o_conv);
48001         return ret_conv;
48002 }
48003
48004 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48005         LDKExpiryTime a_conv;
48006         a_conv.inner = (void*)(a & (~1));
48007         a_conv.is_owned = false;
48008         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48009         LDKExpiryTime b_conv;
48010         b_conv.inner = (void*)(b & (~1));
48011         b_conv.is_owned = false;
48012         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48013         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
48014         return ret_conv;
48015 }
48016
48017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48018         LDKMinFinalCltvExpiry this_obj_conv;
48019         this_obj_conv.inner = (void*)(this_obj & (~1));
48020         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48022         MinFinalCltvExpiry_free(this_obj_conv);
48023 }
48024
48025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
48026         LDKMinFinalCltvExpiry this_ptr_conv;
48027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
48028         this_ptr_conv.is_owned = false;
48029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48030         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
48031         return ret_conv;
48032 }
48033
48034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48035         LDKMinFinalCltvExpiry this_ptr_conv;
48036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
48037         this_ptr_conv.is_owned = false;
48038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48039         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
48040 }
48041
48042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
48043         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
48044         int64_t ret_ref = 0;
48045         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48046         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48048         ret_ref = (uintptr_t)ret_var.inner;
48049         if (ret_var.is_owned) {
48050                 ret_ref |= 1;
48051         }
48052         return ret_ref;
48053 }
48054
48055 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
48056         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
48057 int64_t ret_ref = 0;
48058 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48059 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48060 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48061 ret_ref = (uintptr_t)ret_var.inner;
48062 if (ret_var.is_owned) {
48063         ret_ref |= 1;
48064 }
48065         return ret_ref;
48066 }
48067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48068         LDKMinFinalCltvExpiry arg_conv;
48069         arg_conv.inner = (void*)(arg & (~1));
48070         arg_conv.is_owned = false;
48071         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48072         int64_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
48073         return ret_conv;
48074 }
48075
48076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48077         LDKMinFinalCltvExpiry orig_conv;
48078         orig_conv.inner = (void*)(orig & (~1));
48079         orig_conv.is_owned = false;
48080         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48081         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
48082         int64_t ret_ref = 0;
48083         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48084         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48085         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48086         ret_ref = (uintptr_t)ret_var.inner;
48087         if (ret_var.is_owned) {
48088                 ret_ref |= 1;
48089         }
48090         return ret_ref;
48091 }
48092
48093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
48094         LDKMinFinalCltvExpiry o_conv;
48095         o_conv.inner = (void*)(o & (~1));
48096         o_conv.is_owned = false;
48097         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48098         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
48099         return ret_conv;
48100 }
48101
48102 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48103         LDKMinFinalCltvExpiry a_conv;
48104         a_conv.inner = (void*)(a & (~1));
48105         a_conv.is_owned = false;
48106         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48107         LDKMinFinalCltvExpiry b_conv;
48108         b_conv.inner = (void*)(b & (~1));
48109         b_conv.is_owned = false;
48110         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48111         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
48112         return ret_conv;
48113 }
48114
48115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48116         if ((this_ptr & 1) != 0) return;
48117         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
48118         CHECK_ACCESS(this_ptr_ptr);
48119         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
48120         FREE((void*)this_ptr);
48121         Fallback_free(this_ptr_conv);
48122 }
48123
48124 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
48125         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48126         *ret_copy = Fallback_clone(arg);
48127 int64_t ret_ref = (uintptr_t)ret_copy;
48128         return ret_ref;
48129 }
48130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48131         LDKFallback* arg_conv = (LDKFallback*)arg;
48132         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
48133         return ret_conv;
48134 }
48135
48136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48137         LDKFallback* orig_conv = (LDKFallback*)orig;
48138         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48139         *ret_copy = Fallback_clone(orig_conv);
48140         int64_t ret_ref = (uintptr_t)ret_copy;
48141         return ret_ref;
48142 }
48143
48144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
48145         
48146         LDKCVec_u8Z program_ref;
48147         program_ref.datalen = (*env)->GetArrayLength(env, program);
48148         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
48149         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
48150         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48151         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
48152         int64_t ret_ref = (uintptr_t)ret_copy;
48153         return ret_ref;
48154 }
48155
48156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
48157         LDKTwentyBytes a_ref;
48158         CHECK((*env)->GetArrayLength(env, a) == 20);
48159         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
48160         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48161         *ret_copy = Fallback_pub_key_hash(a_ref);
48162         int64_t ret_ref = (uintptr_t)ret_copy;
48163         return ret_ref;
48164 }
48165
48166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
48167         LDKTwentyBytes a_ref;
48168         CHECK((*env)->GetArrayLength(env, a) == 20);
48169         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
48170         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48171         *ret_copy = Fallback_script_hash(a_ref);
48172         int64_t ret_ref = (uintptr_t)ret_copy;
48173         return ret_ref;
48174 }
48175
48176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
48177         LDKFallback* o_conv = (LDKFallback*)o;
48178         int64_t ret_conv = Fallback_hash(o_conv);
48179         return ret_conv;
48180 }
48181
48182 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48183         LDKFallback* a_conv = (LDKFallback*)a;
48184         LDKFallback* b_conv = (LDKFallback*)b;
48185         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
48186         return ret_conv;
48187 }
48188
48189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48190         LDKInvoiceSignature this_obj_conv;
48191         this_obj_conv.inner = (void*)(this_obj & (~1));
48192         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48194         InvoiceSignature_free(this_obj_conv);
48195 }
48196
48197 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
48198         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
48199 int64_t ret_ref = 0;
48200 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48201 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48202 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48203 ret_ref = (uintptr_t)ret_var.inner;
48204 if (ret_var.is_owned) {
48205         ret_ref |= 1;
48206 }
48207         return ret_ref;
48208 }
48209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48210         LDKInvoiceSignature arg_conv;
48211         arg_conv.inner = (void*)(arg & (~1));
48212         arg_conv.is_owned = false;
48213         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48214         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
48215         return ret_conv;
48216 }
48217
48218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48219         LDKInvoiceSignature orig_conv;
48220         orig_conv.inner = (void*)(orig & (~1));
48221         orig_conv.is_owned = false;
48222         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48223         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
48224         int64_t ret_ref = 0;
48225         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48226         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48228         ret_ref = (uintptr_t)ret_var.inner;
48229         if (ret_var.is_owned) {
48230                 ret_ref |= 1;
48231         }
48232         return ret_ref;
48233 }
48234
48235 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48236         LDKInvoiceSignature a_conv;
48237         a_conv.inner = (void*)(a & (~1));
48238         a_conv.is_owned = false;
48239         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48240         LDKInvoiceSignature b_conv;
48241         b_conv.inner = (void*)(b & (~1));
48242         b_conv.is_owned = false;
48243         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48244         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
48245         return ret_conv;
48246 }
48247
48248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48249         LDKPrivateRoute this_obj_conv;
48250         this_obj_conv.inner = (void*)(this_obj & (~1));
48251         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48253         PrivateRoute_free(this_obj_conv);
48254 }
48255
48256 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
48257         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
48258 int64_t ret_ref = 0;
48259 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48260 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48261 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48262 ret_ref = (uintptr_t)ret_var.inner;
48263 if (ret_var.is_owned) {
48264         ret_ref |= 1;
48265 }
48266         return ret_ref;
48267 }
48268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48269         LDKPrivateRoute arg_conv;
48270         arg_conv.inner = (void*)(arg & (~1));
48271         arg_conv.is_owned = false;
48272         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48273         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
48274         return ret_conv;
48275 }
48276
48277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48278         LDKPrivateRoute orig_conv;
48279         orig_conv.inner = (void*)(orig & (~1));
48280         orig_conv.is_owned = false;
48281         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48282         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
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
48294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
48295         LDKPrivateRoute o_conv;
48296         o_conv.inner = (void*)(o & (~1));
48297         o_conv.is_owned = false;
48298         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48299         int64_t ret_conv = PrivateRoute_hash(&o_conv);
48300         return ret_conv;
48301 }
48302
48303 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48304         LDKPrivateRoute a_conv;
48305         a_conv.inner = (void*)(a & (~1));
48306         a_conv.is_owned = false;
48307         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48308         LDKPrivateRoute b_conv;
48309         b_conv.inner = (void*)(b & (~1));
48310         b_conv.is_owned = false;
48311         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48312         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
48313         return ret_conv;
48314 }
48315
48316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
48317         LDKSignedRawInvoice this_arg_conv;
48318         this_arg_conv.inner = (void*)(this_arg & (~1));
48319         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
48320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48321         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
48322         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
48323         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
48324         return ((int64_t)ret_conv);
48325 }
48326
48327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
48328         LDKSignedRawInvoice this_arg_conv;
48329         this_arg_conv.inner = (void*)(this_arg & (~1));
48330         this_arg_conv.is_owned = false;
48331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48332         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
48333         int64_t ret_ref = 0;
48334         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48335         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48337         ret_ref = (uintptr_t)ret_var.inner;
48338         if (ret_var.is_owned) {
48339                 ret_ref |= 1;
48340         }
48341         return ret_ref;
48342 }
48343
48344 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48345         LDKSignedRawInvoice this_arg_conv;
48346         this_arg_conv.inner = (void*)(this_arg & (~1));
48347         this_arg_conv.is_owned = false;
48348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48349         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48350         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
48351         return ret_arr;
48352 }
48353
48354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
48355         LDKSignedRawInvoice this_arg_conv;
48356         this_arg_conv.inner = (void*)(this_arg & (~1));
48357         this_arg_conv.is_owned = false;
48358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48359         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
48360         int64_t ret_ref = 0;
48361         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48362         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48364         ret_ref = (uintptr_t)ret_var.inner;
48365         if (ret_var.is_owned) {
48366                 ret_ref |= 1;
48367         }
48368         return ret_ref;
48369 }
48370
48371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
48372         LDKSignedRawInvoice this_arg_conv;
48373         this_arg_conv.inner = (void*)(this_arg & (~1));
48374         this_arg_conv.is_owned = false;
48375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48376         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
48377         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
48378         return (int64_t)ret_conv;
48379 }
48380
48381 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
48382         LDKSignedRawInvoice this_arg_conv;
48383         this_arg_conv.inner = (void*)(this_arg & (~1));
48384         this_arg_conv.is_owned = false;
48385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48386         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
48387         return ret_conv;
48388 }
48389
48390 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48391         LDKRawInvoice this_arg_conv;
48392         this_arg_conv.inner = (void*)(this_arg & (~1));
48393         this_arg_conv.is_owned = false;
48394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48395         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48396         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
48397         return ret_arr;
48398 }
48399
48400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48401         LDKRawInvoice this_arg_conv;
48402         this_arg_conv.inner = (void*)(this_arg & (~1));
48403         this_arg_conv.is_owned = false;
48404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48405         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
48406         int64_t ret_ref = 0;
48407         if ((uintptr_t)ret_var.inner > 4096) {
48408                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48409                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48411                 ret_ref = (uintptr_t)ret_var.inner;
48412                 if (ret_var.is_owned) {
48413                         ret_ref |= 1;
48414                 }
48415         }
48416         return ret_ref;
48417 }
48418
48419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
48420         LDKRawInvoice this_arg_conv;
48421         this_arg_conv.inner = (void*)(this_arg & (~1));
48422         this_arg_conv.is_owned = false;
48423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48424         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
48425         int64_t ret_ref = 0;
48426         if ((uintptr_t)ret_var.inner > 4096) {
48427                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48428                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48430                 ret_ref = (uintptr_t)ret_var.inner;
48431                 if (ret_var.is_owned) {
48432                         ret_ref |= 1;
48433                 }
48434         }
48435         return ret_ref;
48436 }
48437
48438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
48439         LDKRawInvoice this_arg_conv;
48440         this_arg_conv.inner = (void*)(this_arg & (~1));
48441         this_arg_conv.is_owned = false;
48442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48443         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
48444         int64_t ret_ref = 0;
48445         if ((uintptr_t)ret_var.inner > 4096) {
48446                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48447                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48449                 ret_ref = (uintptr_t)ret_var.inner;
48450                 if (ret_var.is_owned) {
48451                         ret_ref |= 1;
48452                 }
48453         }
48454         return ret_ref;
48455 }
48456
48457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48458         LDKRawInvoice this_arg_conv;
48459         this_arg_conv.inner = (void*)(this_arg & (~1));
48460         this_arg_conv.is_owned = false;
48461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48462         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
48463         int64_t ret_ref = 0;
48464         if ((uintptr_t)ret_var.inner > 4096) {
48465                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48466                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48468                 ret_ref = (uintptr_t)ret_var.inner;
48469                 if (ret_var.is_owned) {
48470                         ret_ref |= 1;
48471                 }
48472         }
48473         return ret_ref;
48474 }
48475
48476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
48477         LDKRawInvoice this_arg_conv;
48478         this_arg_conv.inner = (void*)(this_arg & (~1));
48479         this_arg_conv.is_owned = false;
48480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48481         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
48482         int64_t ret_ref = 0;
48483         if ((uintptr_t)ret_var.inner > 4096) {
48484                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48485                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48487                 ret_ref = (uintptr_t)ret_var.inner;
48488                 if (ret_var.is_owned) {
48489                         ret_ref |= 1;
48490                 }
48491         }
48492         return ret_ref;
48493 }
48494
48495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
48496         LDKRawInvoice this_arg_conv;
48497         this_arg_conv.inner = (void*)(this_arg & (~1));
48498         this_arg_conv.is_owned = false;
48499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48500         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
48501         int64_t ret_ref = 0;
48502         if ((uintptr_t)ret_var.inner > 4096) {
48503                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48504                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48506                 ret_ref = (uintptr_t)ret_var.inner;
48507                 if (ret_var.is_owned) {
48508                         ret_ref |= 1;
48509                 }
48510         }
48511         return ret_ref;
48512 }
48513
48514 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
48515         LDKRawInvoice this_arg_conv;
48516         this_arg_conv.inner = (void*)(this_arg & (~1));
48517         this_arg_conv.is_owned = false;
48518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48519         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48520         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
48521         return ret_arr;
48522 }
48523
48524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
48525         LDKRawInvoice this_arg_conv;
48526         this_arg_conv.inner = (void*)(this_arg & (~1));
48527         this_arg_conv.is_owned = false;
48528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48529         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
48530         int64_t ret_ref = 0;
48531         if ((uintptr_t)ret_var.inner > 4096) {
48532                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48533                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48535                 ret_ref = (uintptr_t)ret_var.inner;
48536                 if (ret_var.is_owned) {
48537                         ret_ref |= 1;
48538                 }
48539         }
48540         return ret_ref;
48541 }
48542
48543 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
48544         LDKRawInvoice this_arg_conv;
48545         this_arg_conv.inner = (void*)(this_arg & (~1));
48546         this_arg_conv.is_owned = false;
48547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48548         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
48549         int64_tArray ret_arr = NULL;
48550         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
48551         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
48552         for (size_t o = 0; o < ret_var.datalen; o++) {
48553                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
48554                 int64_t ret_conv_14_ref = 0;
48555                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48556                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48557                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
48558                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
48559                 if (ret_conv_14_var.is_owned) {
48560                         ret_conv_14_ref |= 1;
48561                 }
48562                 ret_arr_ptr[o] = ret_conv_14_ref;
48563         }
48564         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
48565         FREE(ret_var.data);
48566         return ret_arr;
48567 }
48568
48569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
48570         LDKRawInvoice this_arg_conv;
48571         this_arg_conv.inner = (void*)(this_arg & (~1));
48572         this_arg_conv.is_owned = false;
48573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48574         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
48575         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
48576         int64_t ret_ref = (uintptr_t)ret_copy;
48577         return ret_ref;
48578 }
48579
48580 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
48581         LDKRawInvoice 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         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
48586         return ret_conv;
48587 }
48588
48589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
48590         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
48591         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
48592         return (int64_t)ret_conv;
48593 }
48594
48595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
48596         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
48597         *ret_conv = PositiveTimestamp_from_system_time(time);
48598         return (int64_t)ret_conv;
48599 }
48600
48601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
48602         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
48603         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
48604         return (int64_t)ret_conv;
48605 }
48606
48607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
48608         LDKPositiveTimestamp 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         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
48613         return ret_conv;
48614 }
48615
48616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
48617         LDKPositiveTimestamp 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         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
48622         return ret_conv;
48623 }
48624
48625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
48626         LDKPositiveTimestamp this_arg_conv;
48627         this_arg_conv.inner = (void*)(this_arg & (~1));
48628         this_arg_conv.is_owned = false;
48629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48630         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
48631         return ret_conv;
48632 }
48633
48634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
48635         LDKInvoice this_arg_conv;
48636         this_arg_conv.inner = (void*)(this_arg & (~1));
48637         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
48638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48639         this_arg_conv = Invoice_clone(&this_arg_conv);
48640         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
48641         int64_t ret_ref = 0;
48642         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48643         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48645         ret_ref = (uintptr_t)ret_var.inner;
48646         if (ret_var.is_owned) {
48647                 ret_ref |= 1;
48648         }
48649         return ret_ref;
48650 }
48651
48652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
48653         LDKInvoice this_arg_conv;
48654         this_arg_conv.inner = (void*)(this_arg & (~1));
48655         this_arg_conv.is_owned = false;
48656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48657         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
48658         *ret_conv = Invoice_check_signature(&this_arg_conv);
48659         return (int64_t)ret_conv;
48660 }
48661
48662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
48663         LDKSignedRawInvoice signed_invoice_conv;
48664         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
48665         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
48666         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
48667         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
48668         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
48669         *ret_conv = Invoice_from_signed(signed_invoice_conv);
48670         return (int64_t)ret_conv;
48671 }
48672
48673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
48674         LDKInvoice this_arg_conv;
48675         this_arg_conv.inner = (void*)(this_arg & (~1));
48676         this_arg_conv.is_owned = false;
48677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48678         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
48679         return ret_conv;
48680 }
48681
48682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
48683         LDKInvoice this_arg_conv;
48684         this_arg_conv.inner = (void*)(this_arg & (~1));
48685         this_arg_conv.is_owned = false;
48686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48687         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
48688         return ret_conv;
48689 }
48690
48691 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48692         LDKInvoice this_arg_conv;
48693         this_arg_conv.inner = (void*)(this_arg & (~1));
48694         this_arg_conv.is_owned = false;
48695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48696         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48697         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
48698         return ret_arr;
48699 }
48700
48701 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
48702         LDKInvoice this_arg_conv;
48703         this_arg_conv.inner = (void*)(this_arg & (~1));
48704         this_arg_conv.is_owned = false;
48705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48706         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
48707         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
48708         return ret_arr;
48709 }
48710
48711 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
48712         LDKInvoice this_arg_conv;
48713         this_arg_conv.inner = (void*)(this_arg & (~1));
48714         this_arg_conv.is_owned = false;
48715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48716         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48717         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
48718         return ret_arr;
48719 }
48720
48721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
48722         LDKInvoice 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         LDKInvoiceFeatures ret_var = Invoice_features(&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_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
48741         LDKInvoice 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, 33);
48746         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
48747         return ret_arr;
48748 }
48749
48750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
48751         LDKInvoice 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         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
48756         return ret_conv;
48757 }
48758
48759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
48760         LDKInvoice this_arg_conv;
48761         this_arg_conv.inner = (void*)(this_arg & (~1));
48762         this_arg_conv.is_owned = false;
48763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48764         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
48765         return ret_conv;
48766 }
48767
48768 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
48769         LDKInvoice this_arg_conv;
48770         this_arg_conv.inner = (void*)(this_arg & (~1));
48771         this_arg_conv.is_owned = false;
48772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48773         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
48774         return ret_conv;
48775 }
48776
48777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
48778         LDKInvoice this_arg_conv;
48779         this_arg_conv.inner = (void*)(this_arg & (~1));
48780         this_arg_conv.is_owned = false;
48781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48782         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
48783         return ret_conv;
48784 }
48785
48786 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
48787         LDKInvoice this_arg_conv;
48788         this_arg_conv.inner = (void*)(this_arg & (~1));
48789         this_arg_conv.is_owned = false;
48790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48791         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
48792         int64_tArray ret_arr = NULL;
48793         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
48794         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
48795         for (size_t o = 0; o < ret_var.datalen; o++) {
48796                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
48797                 int64_t ret_conv_14_ref = 0;
48798                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48799                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48800                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
48801                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
48802                 if (ret_conv_14_var.is_owned) {
48803                         ret_conv_14_ref |= 1;
48804                 }
48805                 ret_arr_ptr[o] = ret_conv_14_ref;
48806         }
48807         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
48808         FREE(ret_var.data);
48809         return ret_arr;
48810 }
48811
48812 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
48813         LDKInvoice this_arg_conv;
48814         this_arg_conv.inner = (void*)(this_arg & (~1));
48815         this_arg_conv.is_owned = false;
48816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48817         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
48818         int64_tArray ret_arr = NULL;
48819         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
48820         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
48821         for (size_t l = 0; l < ret_var.datalen; l++) {
48822                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
48823                 int64_t ret_conv_11_ref = 0;
48824                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48825                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48826                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
48827                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
48828                 if (ret_conv_11_var.is_owned) {
48829                         ret_conv_11_ref |= 1;
48830                 }
48831                 ret_arr_ptr[l] = ret_conv_11_ref;
48832         }
48833         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
48834         FREE(ret_var.data);
48835         return ret_arr;
48836 }
48837
48838 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
48839         LDKInvoice this_arg_conv;
48840         this_arg_conv.inner = (void*)(this_arg & (~1));
48841         this_arg_conv.is_owned = false;
48842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48843         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
48844         return ret_conv;
48845 }
48846
48847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
48848         LDKInvoice this_arg_conv;
48849         this_arg_conv.inner = (void*)(this_arg & (~1));
48850         this_arg_conv.is_owned = false;
48851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48852         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
48853         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
48854         int64_t ret_ref = (uintptr_t)ret_copy;
48855         return ret_ref;
48856 }
48857
48858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
48859         LDKStr description_conv = java_to_owned_str(env, description);
48860         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
48861         *ret_conv = Description_new(description_conv);
48862         return (int64_t)ret_conv;
48863 }
48864
48865 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
48866         LDKDescription this_arg_conv;
48867         this_arg_conv.inner = (void*)(this_arg & (~1));
48868         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
48869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48870         this_arg_conv = Description_clone(&this_arg_conv);
48871         LDKStr ret_str = Description_into_inner(this_arg_conv);
48872         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48873         Str_free(ret_str);
48874         return ret_conv;
48875 }
48876
48877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
48878         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
48879         int64_t ret_ref = 0;
48880         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48881         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48883         ret_ref = (uintptr_t)ret_var.inner;
48884         if (ret_var.is_owned) {
48885                 ret_ref |= 1;
48886         }
48887         return ret_ref;
48888 }
48889
48890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
48891         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
48892         int64_t ret_ref = 0;
48893         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48894         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48896         ret_ref = (uintptr_t)ret_var.inner;
48897         if (ret_var.is_owned) {
48898                 ret_ref |= 1;
48899         }
48900         return ret_ref;
48901 }
48902
48903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
48904         LDKExpiryTime this_arg_conv;
48905         this_arg_conv.inner = (void*)(this_arg & (~1));
48906         this_arg_conv.is_owned = false;
48907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48908         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
48909         return ret_conv;
48910 }
48911
48912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
48913         LDKExpiryTime this_arg_conv;
48914         this_arg_conv.inner = (void*)(this_arg & (~1));
48915         this_arg_conv.is_owned = false;
48916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48917         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
48918         return ret_conv;
48919 }
48920
48921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
48922         LDKRouteHint hops_conv;
48923         hops_conv.inner = (void*)(hops & (~1));
48924         hops_conv.is_owned = (hops & 1) || (hops == 0);
48925         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
48926         hops_conv = RouteHint_clone(&hops_conv);
48927         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
48928         *ret_conv = PrivateRoute_new(hops_conv);
48929         return (int64_t)ret_conv;
48930 }
48931
48932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
48933         LDKPrivateRoute this_arg_conv;
48934         this_arg_conv.inner = (void*)(this_arg & (~1));
48935         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
48936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48937         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
48938         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
48939         int64_t ret_ref = 0;
48940         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48941         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48943         ret_ref = (uintptr_t)ret_var.inner;
48944         if (ret_var.is_owned) {
48945                 ret_ref |= 1;
48946         }
48947         return ret_ref;
48948 }
48949
48950 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48951         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
48952         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
48953         return ret_conv;
48954 }
48955
48956 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
48957         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
48958         return ret_conv;
48959 }
48960
48961 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
48962         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
48963         return ret_conv;
48964 }
48965
48966 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
48967         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
48968         return ret_conv;
48969 }
48970
48971 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
48972         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
48973         return ret_conv;
48974 }
48975
48976 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
48977         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
48978         return ret_conv;
48979 }
48980
48981 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48982         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
48983         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
48984         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
48985         return ret_conv;
48986 }
48987
48988 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48989         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
48990         LDKStr ret_str = CreationError_to_str(o_conv);
48991         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48992         Str_free(ret_str);
48993         return ret_conv;
48994 }
48995
48996 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48997         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
48998         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
48999         return ret_conv;
49000 }
49001
49002 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
49003         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
49004         return ret_conv;
49005 }
49006
49007 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
49008         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
49009         return ret_conv;
49010 }
49011
49012 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
49013         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
49014         return ret_conv;
49015 }
49016
49017 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
49018         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
49019         return ret_conv;
49020 }
49021
49022 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
49023         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
49024         return ret_conv;
49025 }
49026
49027 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
49028         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
49029         return ret_conv;
49030 }
49031
49032 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
49033         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
49034         return ret_conv;
49035 }
49036
49037 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
49038         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
49039         return ret_conv;
49040 }
49041
49042 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
49043         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
49044         return ret_conv;
49045 }
49046
49047 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
49048         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
49049         return ret_conv;
49050 }
49051
49052 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49053         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
49054         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
49055         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
49056         return ret_conv;
49057 }
49058
49059 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49060         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
49061         LDKStr ret_str = SemanticError_to_str(o_conv);
49062         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49063         Str_free(ret_str);
49064         return ret_conv;
49065 }
49066
49067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49068         if ((this_ptr & 1) != 0) return;
49069         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49070         CHECK_ACCESS(this_ptr_ptr);
49071         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
49072         FREE((void*)this_ptr);
49073         SignOrCreationError_free(this_ptr_conv);
49074 }
49075
49076 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
49077         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49078         *ret_copy = SignOrCreationError_clone(arg);
49079 int64_t ret_ref = (uintptr_t)ret_copy;
49080         return ret_ref;
49081 }
49082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49083         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
49084         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
49085         return ret_conv;
49086 }
49087
49088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49089         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
49090         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49091         *ret_copy = SignOrCreationError_clone(orig_conv);
49092         int64_t ret_ref = (uintptr_t)ret_copy;
49093         return ret_ref;
49094 }
49095
49096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
49097         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49098         *ret_copy = SignOrCreationError_sign_error();
49099         int64_t ret_ref = (uintptr_t)ret_copy;
49100         return ret_ref;
49101 }
49102
49103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
49104         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
49105         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49106         *ret_copy = SignOrCreationError_creation_error(a_conv);
49107         int64_t ret_ref = (uintptr_t)ret_copy;
49108         return ret_ref;
49109 }
49110
49111 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49112         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
49113         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
49114         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
49115         return ret_conv;
49116 }
49117
49118 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49119         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
49120         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
49121         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49122         Str_free(ret_str);
49123         return ret_conv;
49124 }
49125
49126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49127         LDKInvoicePayer this_obj_conv;
49128         this_obj_conv.inner = (void*)(this_obj & (~1));
49129         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
49130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49131         InvoicePayer_free(this_obj_conv);
49132 }
49133
49134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49135         if ((this_ptr & 1) != 0) return;
49136         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49137         CHECK_ACCESS(this_ptr_ptr);
49138         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
49139         FREE((void*)this_ptr);
49140         Payer_free(this_ptr_conv);
49141 }
49142
49143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49144         if ((this_ptr & 1) != 0) return;
49145         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49146         CHECK_ACCESS(this_ptr_ptr);
49147         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
49148         FREE((void*)this_ptr);
49149         Router_free(this_ptr_conv);
49150 }
49151
49152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Retry_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49153         if ((this_ptr & 1) != 0) return;
49154         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49155         CHECK_ACCESS(this_ptr_ptr);
49156         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
49157         FREE((void*)this_ptr);
49158         Retry_free(this_ptr_conv);
49159 }
49160
49161 static inline uintptr_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
49162         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49163         *ret_copy = Retry_clone(arg);
49164 int64_t ret_ref = (uintptr_t)ret_copy;
49165         return ret_ref;
49166 }
49167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49168         LDKRetry* arg_conv = (LDKRetry*)arg;
49169         int64_t ret_conv = Retry_clone_ptr(arg_conv);
49170         return ret_conv;
49171 }
49172
49173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49174         LDKRetry* orig_conv = (LDKRetry*)orig;
49175         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49176         *ret_copy = Retry_clone(orig_conv);
49177         int64_t ret_ref = (uintptr_t)ret_copy;
49178         return ret_ref;
49179 }
49180
49181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1attempts(JNIEnv *env, jclass clz, int64_t a) {
49182         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49183         *ret_copy = Retry_attempts(a);
49184         int64_t ret_ref = (uintptr_t)ret_copy;
49185         return ret_ref;
49186 }
49187
49188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1timeout(JNIEnv *env, jclass clz, int64_t a) {
49189         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49190         *ret_copy = Retry_timeout(a);
49191         int64_t ret_ref = (uintptr_t)ret_copy;
49192         return ret_ref;
49193 }
49194
49195 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Retry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49196         LDKRetry* a_conv = (LDKRetry*)a;
49197         LDKRetry* b_conv = (LDKRetry*)b;
49198         jboolean ret_conv = Retry_eq(a_conv, b_conv);
49199         return ret_conv;
49200 }
49201
49202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1hash(JNIEnv *env, jclass clz, int64_t o) {
49203         LDKRetry* o_conv = (LDKRetry*)o;
49204         int64_t ret_conv = Retry_hash(o_conv);
49205         return ret_conv;
49206 }
49207
49208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49209         if ((this_ptr & 1) != 0) return;
49210         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49211         CHECK_ACCESS(this_ptr_ptr);
49212         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
49213         FREE((void*)this_ptr);
49214         PaymentError_free(this_ptr_conv);
49215 }
49216
49217 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
49218         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49219         *ret_copy = PaymentError_clone(arg);
49220 int64_t ret_ref = (uintptr_t)ret_copy;
49221         return ret_ref;
49222 }
49223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49224         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
49225         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
49226         return ret_conv;
49227 }
49228
49229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49230         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
49231         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49232         *ret_copy = PaymentError_clone(orig_conv);
49233         int64_t ret_ref = (uintptr_t)ret_copy;
49234         return ret_ref;
49235 }
49236
49237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
49238         LDKStr a_conv = java_to_owned_str(env, a);
49239         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49240         *ret_copy = PaymentError_invoice(a_conv);
49241         int64_t ret_ref = (uintptr_t)ret_copy;
49242         return ret_ref;
49243 }
49244
49245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
49246         LDKLightningError a_conv;
49247         a_conv.inner = (void*)(a & (~1));
49248         a_conv.is_owned = (a & 1) || (a == 0);
49249         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49250         a_conv = LightningError_clone(&a_conv);
49251         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49252         *ret_copy = PaymentError_routing(a_conv);
49253         int64_t ret_ref = (uintptr_t)ret_copy;
49254         return ret_ref;
49255 }
49256
49257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
49258         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
49259         CHECK_ACCESS(a_ptr);
49260         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
49261         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
49262         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49263         *ret_copy = PaymentError_sending(a_conv);
49264         int64_t ret_ref = (uintptr_t)ret_copy;
49265         return ret_ref;
49266 }
49267
49268 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) {
49269         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
49270         CHECK_ACCESS(payer_ptr);
49271         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
49272         if (payer_conv.free == LDKPayer_JCalls_free) {
49273                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49274                 LDKPayer_JCalls_cloned(&payer_conv);
49275         }
49276         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
49277         CHECK_ACCESS(router_ptr);
49278         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
49279         if (router_conv.free == LDKRouter_JCalls_free) {
49280                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49281                 LDKRouter_JCalls_cloned(&router_conv);
49282         }
49283         LDKMultiThreadedLockableScore scorer_conv;
49284         scorer_conv.inner = (void*)(scorer & (~1));
49285         scorer_conv.is_owned = false;
49286         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
49287         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
49288         CHECK_ACCESS(logger_ptr);
49289         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
49290         if (logger_conv.free == LDKLogger_JCalls_free) {
49291                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49292                 LDKLogger_JCalls_cloned(&logger_conv);
49293         }
49294         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
49295         CHECK_ACCESS(event_handler_ptr);
49296         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
49297         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
49298                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49299                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
49300         }
49301         void* retry_ptr = (void*)(((uintptr_t)retry) & ~1);
49302         CHECK_ACCESS(retry_ptr);
49303         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
49304         retry_conv = Retry_clone((LDKRetry*)(((uintptr_t)retry) & ~1));
49305         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_conv);
49306         int64_t ret_ref = 0;
49307         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49308         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49309         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49310         ret_ref = (uintptr_t)ret_var.inner;
49311         if (ret_var.is_owned) {
49312                 ret_ref |= 1;
49313         }
49314         return ret_ref;
49315 }
49316
49317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
49318         LDKInvoicePayer this_arg_conv;
49319         this_arg_conv.inner = (void*)(this_arg & (~1));
49320         this_arg_conv.is_owned = false;
49321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49322         LDKInvoice invoice_conv;
49323         invoice_conv.inner = (void*)(invoice & (~1));
49324         invoice_conv.is_owned = false;
49325         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
49326         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
49327         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
49328         return (int64_t)ret_conv;
49329 }
49330
49331 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) {
49332         LDKInvoicePayer this_arg_conv;
49333         this_arg_conv.inner = (void*)(this_arg & (~1));
49334         this_arg_conv.is_owned = false;
49335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49336         LDKInvoice invoice_conv;
49337         invoice_conv.inner = (void*)(invoice & (~1));
49338         invoice_conv.is_owned = false;
49339         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
49340         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
49341         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
49342         return (int64_t)ret_conv;
49343 }
49344
49345 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) {
49346         LDKInvoicePayer this_arg_conv;
49347         this_arg_conv.inner = (void*)(this_arg & (~1));
49348         this_arg_conv.is_owned = false;
49349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49350         LDKPublicKey pubkey_ref;
49351         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
49352         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
49353         LDKThirtyTwoBytes payment_preimage_ref;
49354         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
49355         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
49356         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
49357         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
49358         return (int64_t)ret_conv;
49359 }
49360
49361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
49362         LDKInvoicePayer this_arg_conv;
49363         this_arg_conv.inner = (void*)(this_arg & (~1));
49364         this_arg_conv.is_owned = false;
49365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49366         unsigned char payment_hash_arr[32];
49367         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
49368         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
49369         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
49370         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
49371 }
49372
49373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
49374         LDKInvoicePayer this_arg_conv;
49375         this_arg_conv.inner = (void*)(this_arg & (~1));
49376         this_arg_conv.is_owned = false;
49377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49378         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
49379         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
49380         return (int64_t)ret_ret;
49381 }
49382
49383 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) {
49384         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49385         CHECK_ACCESS(amt_msat_ptr);
49386         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49387         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49388         LDKThirtyTwoBytes payment_hash_ref;
49389         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
49390         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
49391         LDKStr description_conv = java_to_owned_str(env, description);
49392         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
49393         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
49394         if (phantom_route_hints_constr.datalen > 0)
49395                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
49396         else
49397                 phantom_route_hints_constr.data = NULL;
49398         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
49399         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
49400                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
49401                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
49402                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
49403                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
49404                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
49405                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
49406                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
49407         }
49408         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
49409         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49410         CHECK_ACCESS(keys_manager_ptr);
49411         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49412         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49413                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49414                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49415         }
49416         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49417         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49418         *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);
49419         return (int64_t)ret_conv;
49420 }
49421
49422 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) {
49423         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49424         CHECK_ACCESS(amt_msat_ptr);
49425         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49426         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49427         LDKThirtyTwoBytes payment_hash_ref;
49428         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
49429         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
49430         LDKSha256 description_hash_conv;
49431         description_hash_conv.inner = (void*)(description_hash & (~1));
49432         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
49433         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
49434         description_hash_conv = Sha256_clone(&description_hash_conv);
49435         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
49436         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
49437         if (phantom_route_hints_constr.datalen > 0)
49438                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
49439         else
49440                 phantom_route_hints_constr.data = NULL;
49441         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
49442         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
49443                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
49444                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
49445                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
49446                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
49447                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
49448                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
49449                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
49450         }
49451         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
49452         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49453         CHECK_ACCESS(keys_manager_ptr);
49454         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49455         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49456                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49457                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49458         }
49459         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49460         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49461         *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);
49462         return (int64_t)ret_conv;
49463 }
49464
49465 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) {
49466         LDKChannelManager channelmanager_conv;
49467         channelmanager_conv.inner = (void*)(channelmanager & (~1));
49468         channelmanager_conv.is_owned = false;
49469         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
49470         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49471         CHECK_ACCESS(keys_manager_ptr);
49472         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49473         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49474                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49475                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49476         }
49477         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49478         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49479         CHECK_ACCESS(amt_msat_ptr);
49480         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49481         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49482         LDKStr description_conv = java_to_owned_str(env, description);
49483         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49484         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv, invoice_expiry_delta_secs);
49485         return (int64_t)ret_conv;
49486 }
49487
49488 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) {
49489         LDKChannelManager channelmanager_conv;
49490         channelmanager_conv.inner = (void*)(channelmanager & (~1));
49491         channelmanager_conv.is_owned = false;
49492         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
49493         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49494         CHECK_ACCESS(keys_manager_ptr);
49495         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49496         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49497                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49498                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49499         }
49500         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49501         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49502         CHECK_ACCESS(amt_msat_ptr);
49503         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49504         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49505         LDKSha256 description_hash_conv;
49506         description_hash_conv.inner = (void*)(description_hash & (~1));
49507         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
49508         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
49509         description_hash_conv = Sha256_clone(&description_hash_conv);
49510         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49511         *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);
49512         return (int64_t)ret_conv;
49513 }
49514
49515 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) {
49516         LDKChannelManager channelmanager_conv;
49517         channelmanager_conv.inner = (void*)(channelmanager & (~1));
49518         channelmanager_conv.is_owned = false;
49519         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
49520         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49521         CHECK_ACCESS(keys_manager_ptr);
49522         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49523         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49524                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49525                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49526         }
49527         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49528         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49529         CHECK_ACCESS(amt_msat_ptr);
49530         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49531         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49532         LDKSha256 description_hash_conv;
49533         description_hash_conv.inner = (void*)(description_hash & (~1));
49534         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
49535         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
49536         description_hash_conv = Sha256_clone(&description_hash_conv);
49537         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49538         *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);
49539         return (int64_t)ret_conv;
49540 }
49541
49542 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) {
49543         LDKChannelManager channelmanager_conv;
49544         channelmanager_conv.inner = (void*)(channelmanager & (~1));
49545         channelmanager_conv.is_owned = false;
49546         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
49547         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49548         CHECK_ACCESS(keys_manager_ptr);
49549         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49550         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49551                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49552                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49553         }
49554         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49555         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49556         CHECK_ACCESS(amt_msat_ptr);
49557         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49558         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49559         LDKStr description_conv = java_to_owned_str(env, description);
49560         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49561         *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);
49562         return (int64_t)ret_conv;
49563 }
49564
49565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49566         LDKDefaultRouter this_obj_conv;
49567         this_obj_conv.inner = (void*)(this_obj & (~1));
49568         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
49569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49570         DefaultRouter_free(this_obj_conv);
49571 }
49572
49573 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) {
49574         LDKNetworkGraph network_graph_conv;
49575         network_graph_conv.inner = (void*)(network_graph & (~1));
49576         network_graph_conv.is_owned = false;
49577         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
49578         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
49579         CHECK_ACCESS(logger_ptr);
49580         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
49581         if (logger_conv.free == LDKLogger_JCalls_free) {
49582                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49583                 LDKLogger_JCalls_cloned(&logger_conv);
49584         }
49585         LDKThirtyTwoBytes random_seed_bytes_ref;
49586         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
49587         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
49588         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
49589         int64_t ret_ref = 0;
49590         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49591         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49593         ret_ref = (uintptr_t)ret_var.inner;
49594         if (ret_var.is_owned) {
49595                 ret_ref |= 1;
49596         }
49597         return ret_ref;
49598 }
49599
49600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
49601         LDKDefaultRouter this_arg_conv;
49602         this_arg_conv.inner = (void*)(this_arg & (~1));
49603         this_arg_conv.is_owned = false;
49604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49605         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
49606         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
49607         return (int64_t)ret_ret;
49608 }
49609
49610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
49611         LDKChannelManager this_arg_conv;
49612         this_arg_conv.inner = (void*)(this_arg & (~1));
49613         this_arg_conv.is_owned = false;
49614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49615         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
49616         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
49617         return (int64_t)ret_ret;
49618 }
49619
49620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
49621         LDKStr s_conv = java_to_owned_str(env, s);
49622         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
49623         *ret_conv = SiPrefix_from_str(s_conv);
49624         return (int64_t)ret_conv;
49625 }
49626
49627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
49628         LDKStr s_conv = java_to_owned_str(env, s);
49629         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
49630         *ret_conv = Invoice_from_str(s_conv);
49631         return (int64_t)ret_conv;
49632 }
49633
49634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
49635         LDKStr s_conv = java_to_owned_str(env, s);
49636         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
49637         *ret_conv = SignedRawInvoice_from_str(s_conv);
49638         return (int64_t)ret_conv;
49639 }
49640
49641 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49642         LDKParseError* o_conv = (LDKParseError*)o;
49643         LDKStr ret_str = ParseError_to_str(o_conv);
49644         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49645         Str_free(ret_str);
49646         return ret_conv;
49647 }
49648
49649 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49650         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
49651         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
49652         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49653         Str_free(ret_str);
49654         return ret_conv;
49655 }
49656
49657 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49658         LDKInvoice o_conv;
49659         o_conv.inner = (void*)(o & (~1));
49660         o_conv.is_owned = false;
49661         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49662         LDKStr ret_str = Invoice_to_str(&o_conv);
49663         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49664         Str_free(ret_str);
49665         return ret_conv;
49666 }
49667
49668 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49669         LDKSignedRawInvoice o_conv;
49670         o_conv.inner = (void*)(o & (~1));
49671         o_conv.is_owned = false;
49672         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49673         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
49674         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49675         Str_free(ret_str);
49676         return ret_conv;
49677 }
49678
49679 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49680         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
49681         LDKStr ret_str = Currency_to_str(o_conv);
49682         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49683         Str_free(ret_str);
49684         return ret_conv;
49685 }
49686
49687 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49688         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
49689         LDKStr ret_str = SiPrefix_to_str(o_conv);
49690         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49691         Str_free(ret_str);
49692         return ret_conv;
49693 }
49694
49695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49696         LDKRapidGossipSync this_obj_conv;
49697         this_obj_conv.inner = (void*)(this_obj & (~1));
49698         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
49699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49700         RapidGossipSync_free(this_obj_conv);
49701 }
49702
49703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph) {
49704         LDKNetworkGraph network_graph_conv;
49705         network_graph_conv.inner = (void*)(network_graph & (~1));
49706         network_graph_conv.is_owned = false;
49707         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
49708         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv);
49709         int64_t ret_ref = 0;
49710         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49711         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49713         ret_ref = (uintptr_t)ret_var.inner;
49714         if (ret_var.is_owned) {
49715                 ret_ref |= 1;
49716         }
49717         return ret_ref;
49718 }
49719
49720 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) {
49721         LDKRapidGossipSync this_arg_conv;
49722         this_arg_conv.inner = (void*)(this_arg & (~1));
49723         this_arg_conv.is_owned = false;
49724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49725         LDKStr sync_path_conv = java_to_owned_str(env, sync_path);
49726         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
49727         *ret_conv = RapidGossipSync_sync_network_graph_with_file_path(&this_arg_conv, sync_path_conv);
49728         return (int64_t)ret_conv;
49729 }
49730
49731 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1is_1initial_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_arg) {
49732         LDKRapidGossipSync this_arg_conv;
49733         this_arg_conv.inner = (void*)(this_arg & (~1));
49734         this_arg_conv.is_owned = false;
49735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49736         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
49737         return ret_conv;
49738 }
49739
49740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49741         if ((this_ptr & 1) != 0) return;
49742         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49743         CHECK_ACCESS(this_ptr_ptr);
49744         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
49745         FREE((void*)this_ptr);
49746         GraphSyncError_free(this_ptr_conv);
49747 }
49748
49749 static inline uintptr_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
49750         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
49751         *ret_copy = GraphSyncError_clone(arg);
49752 int64_t ret_ref = (uintptr_t)ret_copy;
49753         return ret_ref;
49754 }
49755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49756         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)arg;
49757         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
49758         return ret_conv;
49759 }
49760
49761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49762         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)orig;
49763         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
49764         *ret_copy = GraphSyncError_clone(orig_conv);
49765         int64_t ret_ref = (uintptr_t)ret_copy;
49766         return ret_ref;
49767 }
49768
49769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1decode_1error(JNIEnv *env, jclass clz, int64_t a) {
49770         LDKDecodeError a_conv;
49771         a_conv.inner = (void*)(a & (~1));
49772         a_conv.is_owned = (a & 1) || (a == 0);
49773         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49774         a_conv = DecodeError_clone(&a_conv);
49775         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
49776         *ret_copy = GraphSyncError_decode_error(a_conv);
49777         int64_t ret_ref = (uintptr_t)ret_copy;
49778         return ret_ref;
49779 }
49780
49781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1lightning_1error(JNIEnv *env, jclass clz, int64_t a) {
49782         LDKLightningError a_conv;
49783         a_conv.inner = (void*)(a & (~1));
49784         a_conv.is_owned = (a & 1) || (a == 0);
49785         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49786         a_conv = LightningError_clone(&a_conv);
49787         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
49788         *ret_copy = GraphSyncError_lightning_error(a_conv);
49789         int64_t ret_ref = (uintptr_t)ret_copy;
49790         return ret_ref;
49791 }
49792
49793 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) {
49794         LDKRapidGossipSync this_arg_conv;
49795         this_arg_conv.inner = (void*)(this_arg & (~1));
49796         this_arg_conv.is_owned = false;
49797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49798         LDKu8slice update_data_ref;
49799         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
49800         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
49801         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
49802         *ret_conv = RapidGossipSync_update_network_graph(&this_arg_conv, update_data_ref);
49803         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
49804         return (int64_t)ret_conv;
49805 }
49806